您如何设置散点图的样式?

时间:2020-03-15 00:45:49

标签: python matplotlib seaborn

我已使用以下代码使散点图看起来像这样:

plt.scatter(x,y,marker ='|')

enter image description here

现在,我希望它看起来像这样:

enter image description here

我该怎么做?请不要理会背景和橙色线,这是完全不同的图形。谢谢!

2 个答案:

答案 0 :(得分:1)

作为一种解决方法,您可以使用相同的颜色散布两次。另外,请参见here

import numpy as np
from matplotlib import pyplot as plt

xs = np.random.randn(100)
ys = np.random.randn(100)

plt.scatter(xs, ys, color="blue")
plt.scatter(xs, ys, s = 200, marker='|', color='blue')

结果:

enter image description here

答案 1 :(得分:0)

在我看来,您想要实现的是(或至少看起来类似于)“点加错误栏”标记样式。如果您不绘制误差线,则我强烈建议您不要使用此样式。如果您想绘制误差线,我建议

plt.errorbar(xs, ys, dys, marker='.', ls='')

假设dys是y维度中的错误(不确定性)。