フィルターのクリア

How to overlay single data points on bar graph in MATLAB?

39 ビュー (過去 30 日間)
Prashanti Ganesh
Prashanti Ganesh 2021 年 3 月 17 日
回答済み: Cris LaPierre 2021 年 3 月 17 日
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')

採用された回答

Cris LaPierre
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 件)

カテゴリ

Help Center および File ExchangeBar Plots についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by