@@ -842,7 +842,7 @@ def rc_params_from_file(fname, fail_on_error=False, use_default_template=True):
842
842
Parameters
843
843
----------
844
844
fname : str or path-like
845
- Name of file parsed for Matplotlib settings.
845
+ A file with Matplotlib rc settings.
846
846
fail_on_error : bool
847
847
If True, raise an error when the parser fails to convert a parameter.
848
848
use_default_template : bool
@@ -1019,8 +1019,8 @@ def rc_file(fname, *, use_default_template=True):
1019
1019
1020
1020
Parameters
1021
1021
----------
1022
- fname : str
1023
- Name of file parsed for matplotlib settings.
1022
+ fname : str or path-like
1023
+ A file with Matplotlib rc settings.
1024
1024
1025
1025
use_default_template : bool
1026
1026
If True, initialize with default parameters before updating with those
@@ -1040,29 +1040,35 @@ def rc_file(fname, *, use_default_template=True):
1040
1040
@contextlib .contextmanager
1041
1041
def rc_context (rc = None , fname = None ):
1042
1042
"""
1043
- Return a context manager for managing rc settings.
1044
-
1045
- This allows one to do::
1043
+ Return a context manager for temporarily changing rcParams.
1046
1044
1047
- with mpl.rc_context(fname='screen.rc'):
1048
- plt.plot(x, a) # uses 'screen.rc'
1049
- with mpl.rc_context(fname='print.rc'):
1050
- plt.plot(x, b) # uses 'print.rc'
1051
- plt.plot(x, c) # uses 'screen.rc'
1052
-
1053
- A dictionary can also be passed to the context manager::
1045
+ Parameters
1046
+ ----------
1047
+ rc : dict
1048
+ The rcParams to temporarily set.
1049
+ fname : str or path-like
1050
+ A file with Matplotlib rc settings. If both *fname* and *rc* are given,
1051
+ settings from *rc* take precedence.
1054
1052
1055
- with mpl.rc_context(rc={'text.usetex': True}, fname='screen.rc'):
1056
- plt.plot(x, a)
1053
+ See Also
1054
+ --------
1055
+ :ref:`customizing-with-matplotlibrc-files`
1057
1056
1058
- The *rc* dictionary takes precedence over the settings loaded from *fname*.
1059
- Passing a dictionary only is also valid. For example, a common usage is::
1057
+ Examples
1058
+ --------
1059
+ Passing explicit values via a dict::
1060
1060
1061
1061
with mpl.rc_context({'interactive': False}):
1062
1062
fig, ax = plt.subplots()
1063
1063
ax.plot(range(3), range(3))
1064
- fig.savefig('A.png', format=' png')
1064
+ fig.savefig('example. png')
1065
1065
plt.close(fig)
1066
+
1067
+ Loading settings from a file::
1068
+
1069
+ with mpl.rc_context(fname='print.rc'):
1070
+ plt.plot(x, y) # uses 'print.rc'
1071
+
1066
1072
"""
1067
1073
orig = rcParams .copy ()
1068
1074
try :
0 commit comments