Plot many horizontal Bar Plots in the same graph

限于喜欢 提交于 2019-11-27 07:18:16

问题


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:

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

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

thanks.


回答1:


Using 'Position' of axes property

% 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



来源:https://stackoverflow.com/questions/16380472/plot-many-horizontal-bar-plots-in-the-same-graph

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!