我正在尝试使用matlab中的grouped scatterhist
函数制作子图。
subplot(2,2,1)
scatterhist(x,y,'Group',factor)
subplot(2,2,2)
scatterhist(x,y,'Group',factor)
这使得第二个子图的一个正常大小的图。有任何想法吗?
答案 0 :(得分:2)
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
值的函数,具体取决于图中你想要多少个子图。