Plot many horizontal Bar Plots in the same graph

前端 未结 1 1423
独厮守ぢ
独厮守ぢ 2020-12-11 10:27

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:

相关标签:
1条回答
  • 2020-12-11 10:50

    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
    

    enter image description here

    0 讨论(0)
提交回复
热议问题