3
我正在试图定制matplotlib图中的次要勾号。请看下面的代码:Matplotlib次要勾号
import pylab as pl
from matplotlib.ticker import AutoMinorLocator
fig, ax = pl.subplots(figsize=(11., 7.4))
x = [1,2,3, 4]
y = [10, 45, 77, 55]
errorb = [20,66,58,11]
pl.xscale("log")
ax.xaxis.set_minor_locator(AutoMinorLocator(2))
ax.yaxis.set_minor_locator(AutoMinorLocator(2))
pl.tick_params(which='both', width=1)
pl.tick_params(which='minor', length=4, color='g')
pl.tick_params(axis ='both', which='major', length=8, labelsize =20, color='r')
pl.errorbar(x, y, yerr=errorb)
#pl.plot(x, y)
pl.show()
据我了解,AutoMinorLocator(n)
应该是每个主刻度之间插入N次刻度,这是线性比例会发生什么,但根本无法找出逻辑布局的背后在一个logscale上的小勾号。最重要的是,当使用errorbar()
,然后使用简单的plot()
时,会有更多次要的滴答声。
工作就像一个魅力!感谢您的彻底解答! – Botond