4

当我使用 plt.errorbars 时,我希望灰点根本不会出现在空心圆圈符号内。我发现了一个类似的问题,但它使用了 ggplot。

误差线通过开放符号显示

除非别无选择,否则我想坚持使用 pyplot。我的代码如下。提前致谢。

import numpy as np
import matplotlib.pyplot as plt

x = np.arange(0,5,0.1)
y = np.sin(x)
yerr = np.random.randint(2,size=len(x))
plt.errorbar(x,y,yerr=yerr, color='gray', fmt='.', zorder=1)
plt.plot(x,y,'ro', mfc='none', label='My work')
plt.legend(numpoints=1)
plt.show() 

在此处输入图像描述

4

1 回答 1

4

使用fmt='o'

plt.errorbar(x,y,yerr=yerr, color='gray', fmt='o', mfc='white', zorder=1)

包括mfc='white'将标记的背景颜色设置为白色。

其他角色见剧情。fmt

于 2013-08-13T14:57:20.573 回答