I am frequently making plots for my own research and all of the default settings are fine, but often have to switch over to making plots designed for talks/presentations; I manually set all of the font sizes a bit bigger for easier reading:
plot(xdata, ydata)
xlabel("x-axis data", fontsize=20)
ax = gca()
for labeltick in ax.xaxis.get_majorticklabels() + ax.yaxis.get_majorticklabels():
labeltick.set_fontsize(15)
and so on.
Thanks to documentation and questions like this one I know how to control default plotting parameters when I start up matplotlib. I thought about writing something really quick (mpl_defaults.py):
import matplotlib as mpl
def plot_for_talks():
mpl.rcParams['font.size'] = 20
mpl.rcParams['figure.subplot.left'] = .2
mpl.rcParams['figure.subplot.right'] = .8
mpl.rcParams['figure.subplot.bottom'] = .2
mpl.rcParams['figure.subplot.top'] = .8
Then my plotting code could just include
import mpl_defaults
plot_for_talks()
My question: is there a more appropriate way to do this? Maybe something already built in?
Try this:
import matplotlib as mpl
mpl.rc('figure.subplot', left=.2, right=.8, bottom=.2, top=.8)
And there should be a "site-packages/matplotlib/mpl-data/matplotlibrc" file, described in doc 5.1.
Use mpl.matplotlib_fname() to get your rc file path, and modify it so the setting will be permanent.