python - matplotlib fill_ Between 显示点

标签 python matplotlib

我正在使用 subplot2grid 并尝试使 fill_ Between() 适用于第二个子图。

它确实有效,但由于某种原因它显示橙色点。我怎样才能去掉这些点?

注意第二个子图中的橙色点 enter image description here

最后 3 行代码是 fill_ Between() 出现的地方,但发布了图表的所有相关代码(数据位于 pandas 数据框中)

length = len(df.index)

fig6    = plt.figure(figsize=(14,11))
ax1_f6  = plt.subplot2grid((9,1),(0,0), rowspan=5, colspan=1)
titulo  = "{0} ".format(assets[0])
fig6.suptitle(titulo, fontsize=15, color='#0079a3')


            # V.1) data for first subplot
x6      = mdates.date2num(df.index[-length:].to_pydatetime())
y6      = df.PX_LAST[-length:].values
z6      = df.trend_noise_thr_mean[-length:].values
cmap    = ListedColormap(['r','y','g'])
norm    = BoundaryNorm([-1.5,-1,0,1,1.5], cmap.N) 

points  = np.array([x6,y6]).T.reshape(-1, 1, 2)
segments= np.concatenate([points[:-1], points[1:]], axis=1)

lc = LineCollection(segments, cmap=cmap, norm=norm)
lc.set_array(z6)
lc.set_linewidth(3)

ax1_f6=plt.gca()
ax1_f6.add_collection(lc)
ax1_f6.set_xlim(x6.min(), x6.max())
ax1_f6.set_ylim(y6.min(), y6.max())
ax1_f6.xaxis.set_major_formatter(mdates.DateFormatter('%d/%m/%Y'))

ax1_f6.plot(df.emaw.index[-length:], df.emaw[-length:], '-', lw=0.7, label='EMA', color='r')


           # V.2) data of the second subplot 

ax2_f6     = plt.subplot2grid((9,1),(6,0), rowspan=4, colspan=1, sharex=ax1_f6)
axb2_f6    = ax2_f6.twinx() 

test = (df.noise - df.mean)

axb2_f6.plot_date(test.index[-length:], test[-length:], lw=1, label='test')
axb2_f6.fill_between(test.index, test, 0, where=(test >= 0), facecolor='g', alpha=0.3, interpolate=True) 
axb2_f6.fill_between(test.index, test, 0, where=(test < 0), facecolor='r', alpha=0.3, interpolate=True)  

最佳答案

plot_date 默认使用 marker='o'。将marker=None 传递给方法以消除点:

axb2_f6.plot_date(test.index[-length:], marker=None, test[-length:], lw=1, label='test')

关于python - matplotlib fill_ Between 显示点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36436788/

相关文章:

python - 为什么这些代码不能直观地显示从图像中提取的正确颜色?

python - 无法在 python 2.7 上安装 matplotlib

python - 在 matplotlib 中翻转绘图

python - 当 for 循环的变量有一段时间条件时,如何在 for 循环中获得步骤跳转

python - Flask render_template() 在 Azure Web App 中不起作用

python - 如何从左到右提取数字中的数字?

python - 如何在 cartopy/matplotlib 图上显示公里标尺?

python - 生成总和为 M 的 N 个均匀随机数

python - 如何模拟 Elasticsearch Python?

python - wxpython-plotting 中的 Matplotlib 中止