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()
在上面的示例中,是一组4个绘图的简化版本,我想要 所有四个图上的网格线。但是在图4中,我只希望网格化 ax4而不是ax5。Axes对象(ax5)似乎没有简单的设置方法 要关闭的网格打印。 如何有选择地关闭ax5的网格线?我试了以下方法 但它不起作用:
(Pdb) ax5.get_xgridlines()
<a list of 6 Line2D xgridline objects>
(Pdb) ax5.grid(ls=None)
*** AttributeError: 'NoneType' object has no attribute 'startswith'
(Pdb)
我想你只需要关掉电网。(doc)
相关问题 更多 >
编程相关推荐