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

조회 수: 5 (최근 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 CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by