scatterhist
不能很好地与subplot
,所以你必须找到解决方法。
这是一种方法uipanel
.
% create two separate figures with the two scatterplots in
h1 = figure
scatterhist(x,y,'Group',factor)
h2 = figure
scatterhist(x,y,'Group',factor)
% create third figure split into two uipanels
h3 = figure
u1 = uipanel('position',[0,0,0.5,1]);
u2 = uipanel('position',[0.5,0,0.5,1);
% get all children from each figure and move to the uipanels
set(get(h1,'Children'),'parent',u1);
set(get(h2,'Children'),'parent',u2);
%close unneeded figures
close(h1,h2)
如果您想做很多这样的事情,您可能需要创建一个能够正确计算的函数position
值取决于您想要在图中有多少个子图。