2

我需要绘制一个 xy 函数,它显示 x 值处的直方图。类似于下图的底部图:

一组垂直直方图

我尝试使用 matlab 的“barh”,但不能在同一个图中绘制很多。有任何想法吗?

或者,也许替换连续图的原点(基线,barseries 属性中的基值)会起作用。我怎么能为barh做到这一点?

谢谢。

4

1 回答 1

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

在此处输入图像描述

于 2013-05-05T13:02:44.370 回答