我无法绘制错误我确切想要的
我想在两个方向上都用错误栏绘制。我的错误值是标准错误。因此,我希望误差线按照它们所属的价值。这是我的代码:
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
column_names = ["gplx", "gplxerror", "hplx", "hplxerror"]
data=pd.read_csv("hw4.csv", names=column_names)
x=data.gplx.to_list()
xerr=data.gplxerror.to_list()
y=data.hplx.to_list()
yerr=data.hplxerror.to_list()
xx = [1/(i/1000) for i in x]
yy = [1/(j/1000) for j in y]
plt.errorbar(xx, yy, xerr, yerr, fmt='o',
ecolor='pink', color='blue')
plt.xlabel('Gaia Distance(in pc)')
plt.ylabel('Hipparcos Distance (in pc)')
plt.savefig('filename.png', dpi=600)
这是我得到的绘图:
,
但是错误栏太大了。我该如何使它们更小?
I want to plot with error bars in both directions. My error values are standard error. So I want the error bars to be according to the value they belong to. Here's my code:
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
column_names = ["gplx", "gplxerror", "hplx", "hplxerror"]
data=pd.read_csv("hw4.csv", names=column_names)
x=data.gplx.to_list()
xerr=data.gplxerror.to_list()
y=data.hplx.to_list()
yerr=data.hplxerror.to_list()
xx = [1/(i/1000) for i in x]
yy = [1/(j/1000) for j in y]
plt.errorbar(xx, yy, xerr, yerr, fmt='o',
ecolor='pink', color='blue')
plt.xlabel('Gaia Distance(in pc)')
plt.ylabel('Hipparcos Distance (in pc)')
plt.savefig('filename.png', dpi=600)
And this is the plot that I get:
But the error bars are too big. How can I make them smaller?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我使用(错误/100 *值)作为每个值的百分比获取错误。它运行良好。检查以下代码:
I used (error/100 * value) to get error as percentage of each value. It worked well. Check the following code: