Reputation: 1380
import pylab
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker
pyplotParams = {
'backend': 'eps',
'axes.labelsize': 8,
'axes.facecolor': '#E5E5E5', # axes background color
'axes.edgecolor': 'k', # axes edge color
'axes.grid': True, # display grid or not
'axes.axisbelow': True, # show grid below plot elements
'grid.color': 'w', # grid color
'grid.linestyle': '-', # grid line style
'figure.dpi': 80,
'figure.facecolor': 'w',
}
rcParams.update(pyplotParams)
fig1 = plt.figure()
ax4 = fig1.add_subplot(111)
ax4.plot(xaxis3_val,cum_ar_250_ret,color='g')
ax4.plot(xaxis3_val,cum_basket_250_ret,color='b')
ax5 = ax4.twinx()
ax5.plot(xaxis3_val,signal,color='r')
plt.show()
In the above example is a cutdown version of a set of 4 plots and I want gridlines on all four plots. However on figure 4, I want gridliness only for ax4 and not ax5. The Axes object (ax5) does not seem to have an easy way to set the printing of the grid to be turned off. How can I selectively turn off the gridlines for ax5? I tried the following but it does not work:
(Pdb) ax5.get_xgridlines()
<a list of 6 Line2D xgridline objects>
(Pdb) ax5.grid(ls=None)
*** AttributeError: 'NoneType' object has no attribute 'startswith'
(Pdb)
Upvotes: 1
Views: 217