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