Return a context manager for temporarily changing rcParams.
The rcParams["backend"] will not be reset by the context manager.
rcParams changed both through the context manager invocation and in the body of the context will be reset on context exit.
The rcParams to temporarily set.
A file with Matplotlib rc settings. If both fname and rc are given, settings from rc take precedence.
See also
Note
This is equivalent to matplotlib.rc_context.
Passing explicit values via a dict:
with mpl.rc_context({'interactive': False}):
fig, ax = plt.subplots()
ax.plot(range(3), range(3))
fig.savefig('example.png')
plt.close(fig)
Loading settings from a file:
with mpl.rc_context(fname='print.rc'):
plt.plot(x, y) # uses 'print.rc'
Setting in the context body:
with mpl.rc_context():
# will be reset
mpl.rcParams['lines.linewidth'] = 5
plt.plot(x, y)
matplotlib.pyplot.rc_context
© 2012–2023 Matplotlib Development Team. All rights reserved.
Licensed under the Matplotlib License Agreement.
https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.rc_context.html