Skip to content

Commit

Permalink
Merge pull request #16287 from anntzer/rcmark
Browse files Browse the repository at this point in the history
Improve markup for rcParams in docs.
  • Loading branch information
jklymak committed Jan 22, 2020
2 parents 47cfa35 + a9db3e1 commit 63cbb60
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 86 deletions.
2 changes: 1 addition & 1 deletion doc/devel/testing.rst
Expand Up @@ -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.

Expand Down
58 changes: 0 additions & 58 deletions examples/color/color_cycler.py

This file was deleted.

4 changes: 2 additions & 2 deletions examples/misc/customize_rc.py
Expand Up @@ -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
Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions examples/style_sheets/grayscale.py
Expand Up @@ -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

Expand Down
21 changes: 11 additions & 10 deletions lib/matplotlib/__init__.py
Expand Up @@ -873,15 +873,15 @@ 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*).
*kwargs* is a dictionary attribute name/value pairs, e.g.,::
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'
Expand Down Expand Up @@ -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
-----
Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -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
Expand Down
8 changes: 3 additions & 5 deletions lib/matplotlib/animation.py
Expand Up @@ -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
Expand Down Expand Up @@ -1263,8 +1261,8 @@ def to_html5_video(self, embed_limit=None):
Convert the animation to an HTML5 ``<video>`` tag.
This saves the animation as an h264 video, encoded in base64
directly into the HTML5 video tag. This respects the rc parameters
for the writer as well as the bitrate. This also makes use of the
directly into the HTML5 video tag. This respects :rc:`animation.writer`
and :rc:`animation.bitrate`. This also makes use of the
``interval`` to control the speed, and uses the ``repeat``
parameter to decide whether to loop.
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/axes/_axes.py
Expand Up @@ -706,7 +706,7 @@ def text(self, x, y, s, fontdict=None, **kwargs):
fontdict : dict, default: None
A dictionary to override the default text properties. If fontdict
is None, the defaults are determined by your rc parameters.
is None, the defaults are determined by `.rcParams`.
Returns
-------
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/backends/backend_pgf.py
Expand Up @@ -186,7 +186,7 @@ class LatexManager:
"""
The LatexManager opens an instance of the LaTeX application for
determining the metrics of text elements. The LaTeX environment can be
modified by setting fonts and/or a custom preamble in the rc parameters.
modified by setting fonts and/or a custom preamble in `.rcParams`.
"""
_unclean_instances = weakref.WeakSet()

Expand Down
5 changes: 2 additions & 3 deletions lib/matplotlib/figure.py
Expand Up @@ -1831,9 +1831,8 @@ def text(self, x, y, s, fontdict=None, **kwargs):
fontdict : dict, optional
A dictionary to override the default text properties. If not given,
the defaults are determined by your rc parameters. Properties
passed as *kwargs* override the corresponding ones given in
*fontdict*.
the defaults are determined by `.rcParams`. Properties passed as
*kwargs* override the corresponding ones given in *fontdict*.
Other Parameters
----------------
Expand Down
2 changes: 1 addition & 1 deletion tutorials/intermediate/color_cycle.py
Expand Up @@ -13,7 +13,7 @@
This example demonstrates two different APIs:
1. Setting the default rc parameter specifying the property cycle.
1. Setting the rc parameter specifying the default property cycle.
This affects all subsequent axes (but not axes already created).
2. Setting the property cycle for a single pair of axes.
Expand Down
2 changes: 1 addition & 1 deletion tutorials/introductory/usage.py
Expand Up @@ -732,7 +732,7 @@ def my_plotter(ax, data1, data2, param_dict):
# -----------------------------------
#
# If you are using the Agg backend (see :ref:`what-is-a-backend`),
# then you can make use of the ``agg.path.chunksize`` rc parameter.
# then you can make use of :rc:`agg.path.chunksize`
# This allows you to specify a chunk size, and any lines with
# greater than that many vertices will be split into multiple
# lines, each of which has no more than ``agg.path.chunksize``
Expand Down

0 comments on commit 63cbb60

Please sign in to comment.