繁体   English   中英

Matlab多条图恒定高度轴

[英]Matlab multiple bar plot constant height axes

我在这个问题中使用该方法,并试图使每组钢筋的高度成比例。 此方法将使.1高度的条与另一根垂直列上的.5高度的条具有相同的高度...我尝试将'XLimMode'设置为manual,将'XLim'设置为常数,但是不起作用。

有谁知道如何确保所有条形图的高度都与相同的“ y”轴(条形高度轴)成比例?

我找到了解决方案,首先找到所有值的最大值( totmaxaxes ),然后在axes off之前添加该行。

totmaxaxes = max(n(:));

% 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); 
   set(sa, 'Xlim', [0,totmaxaxes + totmaxaxes/40])      %ADD THIS! (+ totmaxaxes/4 just assures that your bar doesn't hit the top)
   axis off;
end

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM