matplotlib errorbar由图中的一个因素缩放
我正在绘制来自名为test.csv的CSV文件的数据,该数据的值类似于:
X Y Yerrmin Yerrmax
13.629119553139 0.13237415706937 0.115879894547257 0.14748971609137
55.3872849395824 0.14385506424916 0.13237415706937 0.153752686711682
208.442201941724 0.144454558978827 0.129650059586552 0.158954011478447
544.589674426085 0.151216201294351 0.13515549098632 0.168483298334671
968.990798410664 0.149341335862913 0.135718731529535 0.164331292710806
1305.01533678836 0.146268074690858 0.13073290613871 0.162970154348788
1596.62602210143 0.14748971609137 0.13292580681435 0.165016119097793
在我的代码中,我有:
testK = np.genfromtxt("test.csv", delimiter=",", names=["X", "Y", "Yerrmin", "Yerrmax"])
testK_yerr=[testK['Yerrmin'], testK['Yerrmax']]
plt.errorbar(testK['X'], testK['Y'], yerr=testK_yerr, fmt='sk')
plt.savefig("test_plot.pdf")
我找不到问题为什么错误栏是误差栏的问题乘法因子
I am plotting data from a CSV file named test.csv that has the values like:
X Y Yerrmin Yerrmax
13.629119553139 0.13237415706937 0.115879894547257 0.14748971609137
55.3872849395824 0.14385506424916 0.13237415706937 0.153752686711682
208.442201941724 0.144454558978827 0.129650059586552 0.158954011478447
544.589674426085 0.151216201294351 0.13515549098632 0.168483298334671
968.990798410664 0.149341335862913 0.135718731529535 0.164331292710806
1305.01533678836 0.146268074690858 0.13073290613871 0.162970154348788
1596.62602210143 0.14748971609137 0.13292580681435 0.165016119097793
In my code, I have:
testK = np.genfromtxt("test.csv", delimiter=",", names=["X", "Y", "Yerrmin", "Yerrmax"])
testK_yerr=[testK['Yerrmin'], testK['Yerrmax']]
plt.errorbar(testK['X'], testK['Y'], yerr=testK_yerr, fmt='sk')
plt.savefig("test_plot.pdf")
I cannot find the problem why the error bars are scaled by a multiplicative factor
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的Yerrmin值应小于您想要的错误栏延伸到的数据点的数量。因此,由于您的第一个Y点为0.13,Y误差将延伸至0.13-0.12 = 0.01,这就是它的位置。如果Yerrmin实际上是最小值,即您希望错误频段从0.115延伸至0.147,那么您需要制作新值才能传递到该功能
,然后传递这些值
Your Yerrmin values should be the amount less than the data point that you want the error bar to extend down to. So as your first Y point is 0.13 the Y error will extend down to 0.13-0.12 = 0.01, which is where it is. If Yerrmin is actually the minimum Y value, i.e. you want the error band to extend from 0.115 to 0.147 then you need to make make new values to pass to the function like
and pass those instead