2014-10-01 211 views
-1

如何创建包含Matlab中所有点,以及两个直方图的7 x 5散点图的子图?Matlab - 7乘5散点图的子图?

enter image description here

举例来说,如果你试试这个代码,你会发现它不工作:

x = randn(1,1000); 
y = randn(1,1000); 
subplot(2,2,1); 
scatterhist(x,y) 

我试图从以前的帖子下面的代码:

close all 
h1 = figure 
scatterhist(x,y) 
h2 = figure 
scatterhist(x,y) 

h3 = figure 
u1 = uipanel('position',[0,0,0.5,1]); 
u2 = uipanel('position',[0.5,0,0.5,1]); 

set(get(h1,'Children'),'parent',u1); 
set(get(h2,'Children'),'parent',u2); 

close(h1,h2) 

...这是输出:

enter image description here

我只是跑KevinMc代码,这是什么样子:

enter image description here

谢谢!

+0

你的意思是你想要一个7倍于你在图片中显示的数字?你自己产生了吗? – Hoki 2014-10-01 19:50:23

+0

请澄清这个问题 - 你想要7x5倍图片中生成的3个地块? – Nitay 2014-10-01 19:51:09

+0

没错,那就是我需要的。一个有7x5图的子图矩阵 – 2014-10-01 19:56:03

回答

1

我没有scatterhist,但这里的东西与分散

nCols = 7; 
nRows = 5; 

mainfig = figure; 
for currRow = 1:nRows 
    for currCol = 1:nCols 
     h = figure; 
     scatter(rand(100, 1), randn(100, 1)); 
     figure(mainfig); 
     u(currRow, currCol) = uipanel('Position', [(currCol-1)/nCols, (currRow-1)/nRows, 1/nCols, 1/nRows]); 
     set(get(h, 'Children'), 'parent', u(currRow, currCol)); 
     close(h); 
    end 
end 

个人uipanels存储把手u数组中的作品。

+0

嗨KevinMc,非常感谢。这看起来像我需要的东西,但我仍然想包括直方图...... :(顺便说一句,我张贴了你提供的代码的数字 – 2014-10-02 20:12:05

+0

只需用提供的代码替换scatterhist就可以了。正如我在答案中指出的那样,没有包含scatterhist的包,所以我使用了scatter。 – KevinMc 2014-10-02 23:10:40