python描点画曲线_如何在python中绘制没有曲线的单个点?

我想在绘图上绘制带有误差条的单个数据点,但我不想有曲线.我怎样才能做到这一点?是否有一些“隐形”线条样式,或者我可以将线条样式设置为无色(但标记仍然必须可见)?

所以这是我现在的图表:

plt.errorbar(x5,y5,yerr=error5, fmt='o')

plt.errorbar(x3,y3,yerr=error3, fmt='o')

plt.plot(x3_true,y3_true, 'r--', label=(r'$\lambda = 0.3$'))

plot(x5_true, y5_true, 'b--', label=(r'$\lambda = 0.5$'))

plt.plot(x5,y5, linestyle=':', marker='o', color='red') #this is the 'ideal' curve that I want to add

plt.plot(x3,y3, linestyle=':', marker='o', color='red')

我想保留两条虚曲线,但我不想要两条虚线曲线.我怎样才能做到这一点?如何更改标记的颜色,以便红色曲线的红点,蓝色曲线的蓝点?

解决方法:

您可以使用分散:

import matplotlib.pyplot as plt

import numpy as np

x = np.linspace(0, 2*np.pi, 10)

y = np.sin(x)

plt.scatter(x, y)

plt.show()

或者:

plt.plot(x, y, 's')

编辑:如果你想要错误栏你可以做:

plt.errorbar(x, y, yerr=err, fmt='o')

标签:python,plot,curve,linestyle

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值