本文介绍了在条形图的y轴上突出显示平均值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一个带有y轴值的条形图y = [0:20:40:60:100]默认情况下按条形图设置.现在,我需要标记我的柱线的平均值,假设它是54.5.

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.

我需要在轴上 54.5 .我不希望(0,54.5)带有一些符号,我需要(0,54.5)来显示值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.

推荐答案

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

这篇关于在条形图的y轴上突出显示平均值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 22:04