diff --git a/doc/devel/testing.rst b/doc/devel/testing.rst index be4461991615..ff600d2dab53 100644 --- a/doc/devel/testing.rst +++ b/doc/devel/testing.rst @@ -109,7 +109,7 @@ begin with ``"test_"`` and then within those files for functions beginning with ``"test"`` or classes beginning with ``"Test"``. Some tests have internal side effects that need to be cleaned up after their -execution (such as created figures or modified rc params). The pytest fixture +execution (such as created figures or modified `.rcParams`). The pytest fixture :func:`~matplotlib.testing.conftest.mpl_test_settings` will automatically clean these up; there is no need to do anything further. diff --git a/examples/color/color_cycler.py b/examples/color/color_cycler.py deleted file mode 100644 index 44aa67540884..000000000000 --- a/examples/color/color_cycler.py +++ /dev/null @@ -1,58 +0,0 @@ -""" -=================== -Styling with cycler -=================== - -Demo of custom property-cycle settings to control colors and other style -properties for multi-line plots. - -This example demonstrates two different APIs: - -1. Setting the default :doc:`rc parameter` - specifying the property cycle. This affects all subsequent axes (but not - axes already created). -2. Setting the property cycle for a single pair of axes. -""" -from cycler import cycler -import numpy as np -import matplotlib.pyplot as plt - - -x = np.linspace(0, 2 * np.pi) -offsets = np.linspace(0, 2*np.pi, 4, endpoint=False) -# Create array with shifted-sine curve along each column -yy = np.transpose([np.sin(x + phi) for phi in offsets]) - -# 1. Setting prop cycle on default rc parameter -plt.rc('lines', linewidth=4) -plt.rc('axes', prop_cycle=(cycler(color=['r', 'g', 'b', 'y']) + - cycler(linestyle=['-', '--', ':', '-.']))) -fig, (ax0, ax1) = plt.subplots(nrows=2, constrained_layout=True) -ax0.plot(yy) -ax0.set_title('Set default color cycle to rgby') - -# 2. Define prop cycle for single set of axes -# For the most general use-case, you can provide a cycler to -# `.set_prop_cycle`. -# Here, we use the convenient shortcut that we can alternatively pass -# one or more properties as keyword arguments. This creates and sets -# a cycler iterating simultaneously over all properties. -ax1.set_prop_cycle(color=['c', 'm', 'y', 'k'], lw=[1, 2, 3, 4]) -ax1.plot(yy) -ax1.set_title('Set axes color cycle to cmyk') - -plt.show() - -############################################################################# -# -# ------------ -# -# References -# """""""""" -# -# The use of the following functions, methods, classes and modules is shown -# in this example: - -import matplotlib -matplotlib.axes.Axes.plot -matplotlib.axes.Axes.set_prop_cycle diff --git a/examples/misc/customize_rc.py b/examples/misc/customize_rc.py index 7a5384b9bb08..51873d631932 100644 --- a/examples/misc/customize_rc.py +++ b/examples/misc/customize_rc.py @@ -4,7 +4,7 @@ ============ I'm not trying to make a good looking figure here, but just to show -some examples of customizing rc params on the fly +some examples of customizing `.rcParams` on the fly. If you like to work interactively, and need to create different sets of defaults for figures (e.g., one set of defaults for publication, one @@ -25,8 +25,8 @@ def set_pub(): >>> plot([1, 2, 3]) >>> savefig('myfig') >>> rcdefaults() # restore the defaults - """ + import matplotlib.pyplot as plt plt.subplot(311) diff --git a/examples/style_sheets/grayscale.py b/examples/style_sheets/grayscale.py index bbcab02e0228..5203b0f0b72f 100644 --- a/examples/style_sheets/grayscale.py +++ b/examples/style_sheets/grayscale.py @@ -4,10 +4,10 @@ ===================== This example demonstrates the "grayscale" style sheet, which changes all colors -that are defined as rc parameters to grayscale. Note, however, that not all -plot elements default to colors defined by an rc parameter. - +that are defined as `.rcParams` to grayscale. Note, however, that not all +plot elements respect `.rcParams`. """ + import numpy as np import matplotlib.pyplot as plt diff --git a/lib/matplotlib/__init__.py b/lib/matplotlib/__init__.py index 9cefa1a666b0..35293237513e 100644 --- a/lib/matplotlib/__init__.py +++ b/lib/matplotlib/__init__.py @@ -873,7 +873,7 @@ def rc_params_from_file(fname, fail_on_error=False, use_default_template=True): def rc(group, **kwargs): """ - Set the current rc params. *group* is the grouping for the rc, e.g., + Set the current `.rcParams`. *group* is the grouping for the rc, e.g., for ``lines.linewidth`` the group is ``lines``, for ``axes.facecolor``, the group is ``axes``, and so on. Group may also be a list or tuple of group names, e.g., (*xtick*, *ytick*). @@ -881,7 +881,7 @@ def rc(group, **kwargs): rc('lines', linewidth=2, color='r') - sets the current rc params and is equivalent to:: + sets the current `.rcParams` and is equivalent to:: rcParams['lines.linewidth'] = 2 rcParams['lines.color'] = 'r' @@ -915,7 +915,7 @@ def rc(group, **kwargs): This enables you to easily switch between several configurations. Use ``matplotlib.style.use('default')`` or :func:`~matplotlib.rcdefaults` to - restore the default rc params after changes. + restore the default `.rcParams` after changes. Notes ----- @@ -949,15 +949,16 @@ def rc(group, **kwargs): def rcdefaults(): """ - Restore the rc params from Matplotlib's internal default style. + Restore the `.rcParams` from Matplotlib's internal default style. - Style-blacklisted rc params (defined in + Style-blacklisted `.rcParams` (defined in `matplotlib.style.core.STYLE_BLACKLIST`) are not updated. See Also -------- rc_file_defaults - Restore the rc params from the rc file originally loaded by Matplotlib. + Restore the `.rcParams` from the rc file originally loaded by + Matplotlib. matplotlib.style.use Use a specific style file. Call ``style.use('default')`` to restore the default style. @@ -973,9 +974,9 @@ def rcdefaults(): def rc_file_defaults(): """ - Restore the rc params from the original rc file loaded by Matplotlib. + Restore the `.rcParams` from the original rc file loaded by Matplotlib. - Style-blacklisted rc params (defined in + Style-blacklisted `.rcParams` (defined in `matplotlib.style.core.STYLE_BLACKLIST`) are not updated. """ # Deprecation warnings were already handled when creating rcParamsOrig, no @@ -988,9 +989,9 @@ def rc_file_defaults(): def rc_file(fname, *, use_default_template=True): """ - Update rc params from file. + Update `.rcParams` from file. - Style-blacklisted rc params (defined in + Style-blacklisted `.rcParams` (defined in `matplotlib.style.core.STYLE_BLACKLIST`) are not updated. Parameters diff --git a/lib/matplotlib/animation.py b/lib/matplotlib/animation.py index 062b7674d439..e6063a8d8350 100644 --- a/lib/matplotlib/animation.py +++ b/lib/matplotlib/animation.py @@ -1031,10 +1031,8 @@ def func(current_frame: int, total_frames: int) -> Any construct a `.MovieWriter` instance and can only be passed if *writer* is a string. If they are passed as non-*None* and *writer* is a `.MovieWriter`, a `RuntimeError` will be raised. - """ - # If the writer is None, use the rc param to find the name of the one - # to use + if writer is None: writer = mpl.rcParams['animation.writer'] elif (not isinstance(writer, str) and @@ -1263,8 +1261,8 @@ def to_html5_video(self, embed_limit=None): Convert the animation to an HTML5 ``