EBH*_*EBH 10 matlab plot axes bar-chart matlab-figure
我想在Matlab中制作一个条形图,其中一个类别是"突破顶部"的轴,超过y轴限制,但我无法想象如何做到这一点.当我将上限更改为较低值时,栏会被卡车.
我能做什么?
这是我的数据:
data =
115 116 97 99 107 NaN NaN NaN
111 118 101 114 102 108 111 119
Run Code Online (Sandbox Code Playgroud)
我希望上y轴限制为600.
这是我尝试过的:
bar(data,0.5,'stack')
ylim([0 600])
Run Code Online (Sandbox Code Playgroud)
以下是结果的演示:
EBH*_*EBH 12
一个简单的选项是clipping将轴的属性设置为off.
bar(data,'stack')
colormap('lines') % make it colorfull :)
bax = gca; % get axis handle
bax.Clipping = 'off';
bax.YLim(2) = 600; % set the upper limit
Run Code Online (Sandbox Code Playgroud)
为了获得更好的结果,您可能还需要稍微缩小轴,因此条形图将保持在图中.此外,没有拳击轴更好:
top = bax.YLim(2); % before you change the limit
bax.YLim(2) = 600; % set the upper limit
bax.Position(4) = bax.Position(4)*(bax.YLim(2)/top);
box off
Run Code Online (Sandbox Code Playgroud)
结果: