2013-05-05 107 views
2

我需要繪製一個x-y函數,該函數顯示x值處的直方圖。一些類似下圖的底部曲線:在同一個圖中繪製許多水平條形圖

Set of vertical histograms

我試着使用MATLAB的「BARH」,但不能繪製在同一個圖多。 任何想法?

或者,可能會取代連續繪圖的原點(基線,條紋屬性的基值)。我怎麼能這樣做barh?

謝謝。軸財產

+0

我已經使用'gnuplot'這種需求見過的人。 www.gnuplot.info/ – Bill 2013-05-05 02:03:47

+0

我必須留在matlab中。不過謝謝。 – 2013-05-05 03:20:39

+0

爲每列創建一個不同的軸手柄。使用其「Position」屬性手動定位每個人。 – Shai 2013-05-05 04:57:22

回答

4

使用'Position'

% generate "data" 
m = rand(40,10); 
[n x] = hist(m, 50); 

% the actual plotting 
figure; 
ma = axes('Position',[.1 .1 .8 .8]); % "parent" axes 
N = size(n,2); % number of vertical bars 
for ii=1:N, 
    % create an axes inside the parent axes for the ii-the barh 
    sa = axes('Position', [0.1+(ii-1)*.8/N, 0.1, .8/N, .8]); % position the ii-th barh 
    barh(x, n(:,ii), 'Parent', sa); 
    axis off; 
end 

enter image description here

+0

太好了,非常感謝 – 2013-05-05 13:20:05

+0

如何爲此添加標題?如果我試圖添加一個標題,它顯示在一個奇怪的位置,如果我將軸重置爲「父軸」,我的整個情節就會飛走。 – frickskit 2013-05-09 16:54:16

+0

@frickskit - 我真的沒有太多的經驗。也許發表您的評論作爲一個問題? – Shai 2013-05-09 21:51:28