Suppose that I manually plot several rectangles using the scratch command, as in a bar plot, except these bars have varying widths and lie varying distances apart from one another — as in the example code shown below.
Is there a way to display a string label on the plot for each of these bars individually in one of the following ways?
- Each label lies within the plotted area of the bar that it corresponds to.
- Each label lies along the x-axis just below the midpoint of the bar that it corresponds to.
% ----------------------------------------------------------------------
y = [1 2 3]; LH = [1 5 8]; RH = [2 8 10];colord = {'c','r','k'};for ii = 1 : length(y) patch([LH(ii) LH(ii) RH(ii) RH(ii)], [0 y(ii) y(ii) 0], colord{ii});end % ----------------------------------------------------------------------
Best Answer