条形图上的误差线 [英] Errorbars on bar-graph
本文介绍了条形图上的误差线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试:一个漂亮的组条形图.我想要像这样的误差线(或您自己决定的误差线):
I'm trying to get: a nice bar graph of groups. I'd like error bars on each bar like this (or similar at your discretion):
我有办法:
ff =
Medical eq Patient Hygiene Near bed Far bed
Direct 1.2759 0.9253 0.6092 1.0460 1.3276
Housekeeping 1.0833 0.2500 0.5833 2.1667 1.3333
Mealtimes 0 0.3000 0.7000 1.4500 0.5000
Medication 0.3694 0.7838 0.8919 1.5495 1.0541
Misc 0.1059 0.1294 0.4118 0.8000 0.8353
Personal 0.0370 0.4074 0.8148 1.2593 0.7037
标准偏差
ee =
2.0411 1.1226 0.8378 1.5007 1.3776
1.3114 0.4523 0.6686 2.4058 1.1547
0 0.7327 1.3803 2.1392 0.6070
0.7499 0.9186 1.0300 1.2844 1.3062
0.4371 0.3712 0.7605 1.0212 0.6699
0.1925 0.6939 1.6417 3.5582 1.5644
相反,我得到了:
通过使用:
bb=bar(ff'); hold all
data=repmat([1:6]'*ones(5,1)',1,1)
er=errorbar(data, ff, ee, '.')
我读到我必须找到每个条的中心吗?太疯狂了!有什么解决方法吗?
I read I have to find the centre of each bar? That's crazy! Any workaround?
推荐答案
这真的不是那么疯狂!
您可以仅将errorbar
与现有数据结合使用.
You can just use errorbar
with the data that you have readily available.
此代码通过为每个组加1,为组内的每个条加1/7,来计算正确的位置.
This code computes the correct locations, by adding 1 for every group and 1/7 for each bar within a group.
for i = 1:5
j = 1:6;
x = -0.5 + i + 1/7 * j;
errorbar(x, ff(j,i), ee(j,i), '.');
end
结果:
(省去了标签,但是这似乎与您要查找的内容非常相似)
(Leaving out the labels, but otherwise this seems pretty similar to what you were looking for)
这篇关于条形图上的误差线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文