matplotlib fill_between显示点

时间:2016-04-05 20:49:21

标签: 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)  

1 个答案:

答案 0 :(得分:1)

plot_date默认使用marker='o'。将marker = None传递给摆脱点的方法:

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