Globally set number of ticks. X-axis, Y-axis, colorbar
matplotlib, python
Solution
Why don't you just write a custom module `myplotlib` that sets these defaults as you like them?
import myplt
myplt.setmydefaults()
A global rc setting might break other applications that rely on these settings to be not modified.
Problem
For the font size I like to use I've found that 5 ticks is the most visually pleasing number of ticks across pretty much every axis in matplotlib. I also like to prune the smallest tick along the x-axis to avoid overlapping tick lables. So for almost every plot I make I find myself using the following code. ``` from matplotlib import pyplot as plt from matplotlib.ticker import MaxNLocator plt.imshow( np.random.random(100,100) ) plt.gca().xaxis.set_major_locator( MaxNLocator(nbins = 7, prune = 'lower') ) plt.gca().yaxis.set_major_locator( MaxNLocator(nbins = 6) ) cbar = plt.colorbar() cbar.locator = MaxNLocator( nbins = 6) plt.show() ``` Is there an rc setting I can use so that the default locator for my x-axis, y-axis, and colorbar is by default the above MaxNLocator with the prune option on the x axis?