idexi
idexi

Reputation: 109

Highlight mean value on y-axis in bar chart

So I have a bar chart with y-axis value y = [0:20:40:60:100] as set by bar chart by default. Now I need to mark the mean y value of my bars, so suppose it is 54.5.

I need 54.5 on my axis. I don't want (0, 54.5) to be marked with some sign, I need (0, 54.5) to show the value 54.5, so that I can numerically identify the mean.

Any advicein this regard will be helpful.

Upvotes: 0

Views: 310

Answers (1)

Daniel
Daniel

Reputation: 36710

%random example data
data=rand(10,1)
%create bar plot
bar(data)
%insert mean
m=mean(data)
%draw mean line
line(xlim,[m,m])
%add mean to yticks to show on axis.
set(gca,'YTick',union(get(gca,'YTick'),m))

enter image description here

Upvotes: 1

Related Questions