Highlight mean value on y-axis in bar chart

混江龙づ霸主 提交于 2019-12-12 05:37:27

问题


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.


回答1:


%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))



来源:https://stackoverflow.com/questions/29330754/highlight-mean-value-on-y-axis-in-bar-chart

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!