在同一图中绘制许多水平条形图 [英] Plot many horizontal Bar Plots in the same graph

查看:78
本文介绍了在同一图中绘制许多水平条形图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I need to plot a x-y function, that shows the histograms at x-values. Something similar to the bottom plot of the next figure:

我尝试使用matlab的"barh",但无法在同一图中绘制许多图形. 有什么想法吗?

I tried to use matlab's "barh", but can't plot many in the same figure. Any ideas?

或者,可以替换连续绘图的原点(基准线,barseries属性中的基准值).我该怎么做呢?

Or, maybe displacing the origin (baseline, basevalue in barseries properties) of successive plots would work. How could I do that for barh?

谢谢.

推荐答案

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

这篇关于在同一图中绘制许多水平条形图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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