【问题标题】:Plot many horizontal Bar Plots in the same graph在同一个图中绘制许多水平条形图
【发布时间】:2013-04-29 03:06:55
【问题描述】:

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

我尝试使用 matlab 的“barh”,但无法在同一个图中绘制多个。 有什么想法吗?

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

谢谢。

【问题讨论】:

  • 我看到有人使用gnuplot 来满足这些需求。 www.gnuplot.info/‎
  • 我必须留在matlab中。不过还是谢谢。
  • 为每一列创建不同的坐标区句柄。使用其'Position' 属性手动定位每个。
  • 您能否指出如何使用位置为每列设置新的原点?谢谢!
  • 叠加图像c和绘图显示相同的信息不是更容易吗?

标签: matlab matlab-figure


【解决方案1】:

使用轴属性的'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

【讨论】:

  • 如何给这个添加标题?如果我尝试添加一个标题,它会显示在一个奇怪的位置,如果我将轴重置为“父轴”,我的整个情节就会飞走。
  • @frickskit - 我真的没有太多这方面的经验。也许将您的评论作为问题发表?
  • 你为什么删除这个问题?
  • @FranckDernoncourt 我想出了答案,答案很简单,不值得一提。 (我在这个答案中添加了一个编辑)
猜你喜欢
  • 1970-01-01
  • 2017-03-29
  • 1970-01-01
  • 2019-05-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多