在两个轴上绘制 matplotlib 中的错误栏
Plot error bar in matplotlib on both axes
我想在 python 中的每个轴上绘制带有误差的二维数据点。我使用了来自 matplotlib 的 errorbar
:
x=[393.995,394.87,422.965,423.84,437.49,438.360,466.965,467.84]
y=[1.2625,0.7575,1.2625,0.7575,1.2625,1.7675,2.2725,2.7775]
errors=[0.486731,0.00955756,0.111786,0.412761,0.240057,0.228817,0.222496 ,0.24288]
errorbar(x, y, xerr=errors, yerr=errors, ecolor='k', fmt='o', capthick=2)
但它只显示 y 轴上的错误。我不知道为什么。
剧情:
您的代码没有任何问题。问题是错误和 x
数据的相对值。你根本看不到酒吧。要了解此问题,请查看以下两个示例:
反转 x
和 y
坐标:
x=[393.995,394.87,422.965,423.84,437.49,438.360,466.965,467.84]
y=[1.2625,0.7575,1.2625,0.7575,1.2625,1.7675,2.2725,2.7775]
errors=[0.486731,0.00955756,0.111786,0.412761,0.240057,0.228817,0.222496 ,0.24288]
errorbar(y, x, xerr=errors, yerr=errors, ecolor='k', fmt='o', capthick=2) #invert x and y
减少你的价值x
。
x=[3.93995,3.9487,4.22965,4.2384,4.3749,4.38360,4.66965,4.6784] #x=x/100
y=[1.2625,0.7575,1.2625,0.7575,1.2625,1.7675,2.2725,2.7775]
errors=[0.486731,0.00955756,0.111786,0.412761,0.240057,0.228817,0.222496 ,0.24288]
plt.errorbar(x,y, xerr=errors, yerr=errors, ecolor='k', fmt='o', capthick=2)
我想在 python 中的每个轴上绘制带有误差的二维数据点。我使用了来自 matplotlib 的 errorbar
:
x=[393.995,394.87,422.965,423.84,437.49,438.360,466.965,467.84]
y=[1.2625,0.7575,1.2625,0.7575,1.2625,1.7675,2.2725,2.7775]
errors=[0.486731,0.00955756,0.111786,0.412761,0.240057,0.228817,0.222496 ,0.24288]
errorbar(x, y, xerr=errors, yerr=errors, ecolor='k', fmt='o', capthick=2)
但它只显示 y 轴上的错误。我不知道为什么。
剧情:
您的代码没有任何问题。问题是错误和 x
数据的相对值。你根本看不到酒吧。要了解此问题,请查看以下两个示例:
反转 x
和 y
坐标:
x=[393.995,394.87,422.965,423.84,437.49,438.360,466.965,467.84]
y=[1.2625,0.7575,1.2625,0.7575,1.2625,1.7675,2.2725,2.7775]
errors=[0.486731,0.00955756,0.111786,0.412761,0.240057,0.228817,0.222496 ,0.24288]
errorbar(y, x, xerr=errors, yerr=errors, ecolor='k', fmt='o', capthick=2) #invert x and y
减少你的价值x
。
x=[3.93995,3.9487,4.22965,4.2384,4.3749,4.38360,4.66965,4.6784] #x=x/100
y=[1.2625,0.7575,1.2625,0.7575,1.2625,1.7675,2.2725,2.7775]
errors=[0.486731,0.00955756,0.111786,0.412761,0.240057,0.228817,0.222496 ,0.24288]
plt.errorbar(x,y, xerr=errors, yerr=errors, ecolor='k', fmt='o', capthick=2)