作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
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 个图的简化版本,我想要所有四个地 block 上的网格线。然而在图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)
ax5.grid(False)
关于python - 仅左轴上的网格线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14326338/
我是一名优秀的程序员,十分优秀!