Pyplot错误栏不断将我的点与线连接起来? [英] Pyplot errorbar keeps connecting my points with lines?

查看:41
本文介绍了Pyplot错误栏不断将我的点与线连接起来?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很难让数据点之间的这些线消失!似乎是每当我尝试添加错误栏时都会执行此操作.如果您查看这些图,则第一个没有误差线,而第二个有误差线.这是 pyplot errorbar 的常见副作用吗?有谁知道为什么这样做,或者如何使它消失?

I am having trouble getting these lines between my data points to go away! It seems to be whenever I try to add error bars it does this. If you look at the graphs, the first is without the errorbar line, and the second is with it. Is this a usual side effect of pyplot errorbar? Does anyone know why it does this, or how to make it go away?

plt.figure()
plt.scatter(x, y, label = 'blah')
plt.errorbar(x, y, yerr = None, xerr = x_err) 
plt.plot(x, f) #this is a line of best fit

推荐答案

您可以将线型 (ls) 设置为 'none'(注意: ls=None 不起作用):

You can set the line style (ls) to 'none' (caution: ls=None does not work):

import numpy as np
import matplotlib.pylab as plt

x = np.arange(10)
y = np.arange(10)
yerr = np.random.random(10)
xerr = np.random.random(10)

plt.figure()
plt.subplot(121)
plt.scatter(x, y, label = 'blah')
plt.errorbar(x, y, yerr = None, xerr = xerr) 

plt.subplot(122)
plt.scatter(x, y, label = 'blah')
plt.errorbar(x, y, yerr = None, xerr = xerr, ls='none') 

这篇关于Pyplot错误栏不断将我的点与线连接起来?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆