I usually set rcParams
before plotting anything setting fontsize, figuresize
and other settings to better suit my needs. However for a certain axes
or figure
I would like to change some part of the settings. For example say I set fontsize = 20 in defaults, and for
an inset I add to an axes I would like to change all fontsize to 12. What's the easiest way to achieve it? Currently I am tweaking fontsize of different text i.e label font size, tick label font size etc. by hand!
Is it possible to do something like
Some plotting here with fontsize=20
with fontsize=12 :
inset.plot(x,y)
Set various labels and stuff
Resume plotting with fontsize=20
Matplotlib provides a context manager for rc Parameters rc_context()
. E.g.
from matplotlib import pyplot as plt
rc1 = {"font.size" : 16}
rc2 = {"font.size" : 8}
plt.rcParams.update(rc1)
fig, ax = plt.subplots()
with plt.rc_context(rc2):
axins = ax.inset_axes([0.6, 0.6, 0.37, 0.37])
plt.show()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With