python - matplotlib: what does the parameter `which` do in tick_params -




from matplotlib import pyplot plt . . . plt.tick_params(axis='both', which='major', labelsize=16) 

i checked parameter "which" in matplotlib.pyplot.tick_params. said default 'major'; apply arguments which ticks.

so tried change which='major' 'minor'. seems label size changes smaller. shouldn't label size being controlled parameter 'labelsize'?

i tried change labelsize=16 labelsize=106 while keeping which='minor'. turns out nothing happens.

the argument which indeed selects of "minor", "major", or "both" of them rest of arguments apply.

since default, there no minor ticklabels in matplotlib plot, though change size with

plt.tick_params(axis='both', which='minor', labelsize=16) 

you don't see change. note if had minor ticklabels in plot, size would change.

in below example, turn minor ticks on using locator , turn minor ticklabels on using formatter. ax.tick_params(axis='both', which='minor', labelsize=8) gives minor ticklabels fontsize of 8.

enter image description here

import matplotlib.pyplot plt matplotlib.ticker import multiplelocator, scalarformatter  fig, ax = plt.subplots() ax.plot([0,10,20,30], [0,2,1,2])  ax.xaxis.set_minor_locator(multiplelocator(1)) ax.xaxis.set_minor_formatter(scalarformatter())  ax.tick_params(axis='both', which='major', labelsize=16, pad=12) ax.tick_params(axis='both', which='minor', labelsize=8)  plt.show() 




wiki

Comments

Popular posts from this blog

python - Read npy file directly from S3 StreamingBody -

Asterisk AGI Python Script to Dialplan does not work -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -