数据可视化之matplotlib误差线(一)
2018-06-28 本文已影响3人
truezero
闲来垂钓碧溪上,忽复乘舟梦日边
今天来看误差线的写法。
import numpyas np
import matplotlibas mtp
import matplotlib.pyplotas plt
fig=plt.figure()
x=np.linspace(0,10,50)
print(type(x))
dy=np.linspace(0,10,50)
y=np.sin(x)+dy*np.random.rand(50)
plt.errorbar(x,y,yerr=dy,fmt='k')
print(dy)
plt.show()
这就是一个简单的误差限画法
效果图如下

这个就是误差限,表示y的上下取值范围
同样可以去上下不同限

上下误差限默认第一行为下,第二行为上
左右误差限如图

好了差不多就到这里吗,有疑问请留言一起分析学习