2014-10-01 42 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