How to plot bar with different height and differenth width in matlab?

后端 未结 1 934
傲寒
傲寒 2021-01-14 11:34

I am having a big problem in Matlab, because it seems that I want to do something that is not so usual.

Basically I am trying to implement a way of group distributio

相关标签:
1条回答
  • 2021-01-14 11:54

    The simplest solution is to use rectangle:

    % sample data: set the start of each bar, the bottom (here 0), the width and the height
    
    x = [0.5 0.6 0.9 1 1.2]; % start of bar
    y = zeros(length(x),1);
    dx = diff([x 1.8]); % width of bar
    dy = [1 3 2 .5 .1];
    
    
    figure, hold on
    for ii=1:length(x)
        rectangle('position',[x(ii) y(ii) dx(ii) dy(ii)])
    end
    axis([0.5 2 0 4.1])
    
    ylabel('Prob density')
    xlabel('Time')
    

    enter image description here

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