@@ -842,7 +842,7 @@ def rc_params_from_file(fname, fail_on_error=False, use_default_template=True):
842842 Parameters
843843 ----------
844844 fname : str or path-like
845- Name of file parsed for Matplotlib settings.
845+ A file with Matplotlib rc settings.
846846 fail_on_error : bool
847847 If True, raise an error when the parser fails to convert a parameter.
848848 use_default_template : bool
@@ -1019,8 +1019,8 @@ def rc_file(fname, *, use_default_template=True):
10191019
10201020 Parameters
10211021 ----------
1022- fname : str
1023- Name of file parsed for matplotlib settings.
1022+ fname : str or path-like
1023+ A file with Matplotlib rc settings.
10241024
10251025 use_default_template : bool
10261026 If True, initialize with default parameters before updating with those
@@ -1040,29 +1040,35 @@ def rc_file(fname, *, use_default_template=True):
10401040@contextlib .contextmanager
10411041def rc_context (rc = None , fname = None ):
10421042 """
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.
10461044
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.
10541052
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`
10571056
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::
10601060
10611061 with mpl.rc_context({'interactive': False}):
10621062 fig, ax = plt.subplots()
10631063 ax.plot(range(3), range(3))
1064- fig.savefig('A.png', format=' png')
1064+ fig.savefig('example. png')
10651065 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+
10661072 """
10671073 orig = rcParams .copy ()
10681074 try :
0 commit comments