How to plot bar chart with a layered background?
4 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
Geoff Hayes
2022 年 9 月 2 日
@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.
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Annotations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
