python - Major and minor grid lines and ticks using matplotlib -
i have 2 big intergers
min=round(raw_min,-5) # negative number max=round(raw_max,-5)
from range of interesting ticks:
xticks=np.arange(min,max,500000)
on x-axis, want have minor ticks (including labels) xticks
range. furthermore, want have major tick , grid line @ value 0
. tried add:
minorlocator = fixedlocator(xticks) majorlocator = fixedlocator([0]) ax.xaxis.set_major_locator(majorlocator) ax.xaxis.set_major_formatter(formatstrformatter('%d')) ax.xaxis.set_minor_locator(minorlocator) plt.tick_params(which='both', width=1) plt.tick_params(which='major', length=7, color='b') plt.tick_params(which='minor', length=4, color='r') ax.yaxis.grid(true) ax.xaxis.grid(b=true,which='major', color='b', linestyle='-')
but doesn't work...
no ticks minors , no grid line major.
any ideas?
seems missing following line:
plt.grid(b=true,which='both')
Comments
Post a Comment