Matlab多条图恒定高度轴 [英] Matlab multiple bar plot constant height axes

查看:60
本文介绍了Matlab多条图恒定高度轴的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am using the method in this question and trying to make every set of bars have proportional heights. This method will make a bar of .1 height look the same height as a bar of, say, .5 height on another vertical column... I have tried setting 'XLimMode' to manual and 'XLim' to constant values, but it doesn't work.

有人知道如何确保所有条形图的高度都与SAME的"y"轴(条形高度轴)成比例吗?

Does anyone know how to assure that all the bar charts have heights proportional to the SAME 'y'-axis (height-of-bar axis)?

推荐答案

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

I found a solution, first find the maximum of all your values (totmaxaxes) and then add the line right before 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

这篇关于Matlab多条图恒定高度轴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆