Gabriel
Gabriel

Reputation: 3807

matplotlib fill_between shows dots

I'm using subplot2grid and trying make fill_between() work for the second subplot.

It does work, but for some reason it shows orange dots. How can I get rid of those dots?

Notice the orange dots in the second subplot enter image description here

In the last 3 lines of code is where the fill_between() appears, but posting all the relevant code for the chart (the data is in pandas dataframes)

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)  

Upvotes: 1

Views: 552

Answers (1)

Niemerds
Niemerds

Reputation: 942

plot_date uses marker='o' by default. Pass marker=None to the method to get rid of the dots:

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

Upvotes: 1

Related Questions