How to plot bar chart with a layered background?
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have generated a bar graph consisting of 3 categorical variables, and I would like to "classify" the height of the bar graph by altering the background color (e.g. height less than 10 is green, and height greater than 20 is red). I would also like to set the xlim to be from [0 4] since this would make the graph look more asthetic, but this does not seem to work?
x_groups = categorical({'Jump Height', 'RSI','Stiffness'});
y_height = [30, 15, 26];
b1 = bar(x_groups, y_height);
b1.FaceColor = 'flat';
% Generate the relative patch 'boxes' for classification
box1 = [0 0 4 4]
box_y1 = [0 10 10 0]
box_y2 = [10 20 20 10]
patch(box1, box_y1, [0 1 0], 'FaceAlpha', 0.2)
patch(box1, box_y2, [1 0 0], 'FaceAlpha', 0.2)
I would like to have the bars be in front of the patches. Please help.
2 Kommentare
Geoff Hayes
am 2 Sep. 2022
@Mark Kramer - you may want to look at the accepted answer at https://www.mathworks.com/matlabcentral/answers/8350-how-send-to-back-patch-objects-in-a-graph to get an idea on how to change the order of objects (patches, bars) so that the patch objects are moved to the back. As for changing the x-axes limits, I'm not sure that you can do that when the categories are used for the x-axis.
Antworten (0)
Siehe auch
Kategorien
Mehr zu Annotations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
