matplotlib errorbar由图中的一个因素缩放

发布于 2025-01-22 12:03:05 字数 1163 浏览 0 评论 0原文

我正在绘制来自名为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")

This gives the plot: plot with errorbar

I cannot find the problem why the error bars are scaled by a multiplicative factor

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

淡写薰衣草的香 2025-01-29 12:03:05

您的Yerrmin值应小于您想要的错误栏延伸到的数据点的数量。因此,由于您的第一个Y点为0.13,Y误差将延伸至0.13-0.12 = 0.01,这就是它的位置。如果Yerrmin实际上是最小值,即您希望错误频段从0.115延伸至0.147,那么您需要制作新值才能传递到该功能

testK_yerr=[testk['Y']-testK['Yerrmin'], testK['Yerrmax']-testK['Y']]

,然后传递这些值

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

testK_yerr=[testk['Y']-testK['Yerrmin'], testK['Yerrmax']-testK['Y']]

and pass those instead

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文