How to overlay single data points on bar graph in MATLAB?
28 次查看(过去 30 天)
显示 更早的评论
I am trying to plot a bar graph with means of 9 data points. I want to plot the bar graph with individual data points overlaid on the bar. Here is the code to generate the bar graph. I want to overlay each bar with the individual data points whose average is y. Any suggestions for how to do this would be helpful. Thank you!
x_num = [1:4];
x = categorical({'High PU-High RU','High PU-Low RU', 'Low PU-High RU', 'Low PU-Low RU'});
y = [0.557954545, 0.671394799, 0.543181818, 0.660227273];
figure
bar(x,y,0.4)
title('Economic Performance')
xlabel('Conditions')
0 个评论
采纳的回答
Cris LaPierre
2021-3-17
Here's an example overlaying a datapoint contianing the mean value.
x = categorical({'High PU-High RU','High PU-Low RU', 'Low PU-High RU', 'Low PU-Low RU'});
y = [0.557954545, 0.671394799, 0.543181818, 0.660227273];
bar(x,y,0.4)
title('Economic Performance')
xlabel('Conditions')
hold on
plot(x,y,'o')
hold off
The challenge will perhaps be that all the data for each bar will share the same X value, so all the points will fall in a single line.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Bar Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!