8000 DOC: "Customizing matplotlib" should mention style sheets by wackywendell · Pull Request #4508 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

DOC: "Customizing matplotlib" should mention style sheets #4508

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 9, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 37 additions & 28 deletions doc/users/customizing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,43 @@
Customizing matplotlib
**********************

Using style sheets
==================

Style sheets provide a means for more specific and/or temporary configuration
modifications, but in a repeatable and well-ordered manner. A style sheet is a
file with the same syntax as the :file:`matplotlibrc` file, and when applied, it
will override the :file:`matplotlibrc`.

For more information and examples, see :ref:`style-sheets`.

.. _customizing-with-dynamic-rc-settings:

Dynamic rc settings
===================

You can also dynamically change the default rc settings in a python script or
interactively from the python shell. All of the rc settings are stored in a
dictionary-like variable called :data:`matplotlib.rcParams`, which is global to
the matplotlib package. rcParams can be modified directly, for example::

import matplotlib as mpl
mpl.rcParams['lines.linewidth'] = 2
mpl.rcParams['lines.color'] = 'r'

Matplotlib also provides a couple of convenience functions for modifying rc
settings. The :func:`matplotlib.rc` command can be used to modify multiple
settings in a single group at once, using keyword arguments::

import matplotlib as mpl
mpl.rc('lines', linewidth=2, color='r')

The :func:`matplotlib.rcdefaults` command will restore the standard matplotlib
default settings.

There is some degree of validation when setting the values of rcParams, see
:mod:`matplotlib.rcsetup` for details.

.. _customizing-with-matplotlibrc-files:

The :file:`matplotlibrc` file
Expand Down Expand Up @@ -46,34 +83,6 @@ loaded from, one can do the following::

See below for a sample :ref:`matplotlibrc file<matplotlibrc-sample>`.

.. _customizing-with-dynamic-rc-settings:

Dynamic rc settings
===================

You can also dynamically change the default rc settings in a python script or
interactively from the python shell. All of the rc settings are stored in a
dictionary-like variable called :data:`matplotlib.rcParams`, which is global to
the matplotlib package. rcParams can be modified directly, for example::

import matplotlib as mpl
mpl.rcParams['lines.linewidth'] = 2
mpl.rcParams['lines.color'] = 'r'

Matplotlib also provides a couple of convenience functions for modifying rc
settings. The :func:`matplotlib.rc` command can be used to modify multiple
settings in a single group at once, using keyword arguments::

import matplotlib as mpl
mpl.rc('lines', linewidth=2, color='r')

The :func:`matplotlib.rcdefaults` command will restore the standard matplotlib
default settings.

There is some degree of validation when setting the values of rcParams, see
:mod:`matplotlib.rcsetup` for details.


.. _matplotlibrc-sample:

A sample matplotlibrc file
Expand Down
2 changes: 1 addition & 1 deletion doc/users/style_sheets.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Defining your own style

You can create custom styles and use them by calling ``style.use`` with the
path or URL to the style sheet. Alternatively, if you add your ``<style-name>.mplstyle``
file to ``mpl_configdir/stylelib`, you can reuse your custom style sheet with a call to
file to ``mpl_configdir/stylelib``, you can reuse your custom style sheet with a call to
``style.use(<style-name>)``. By default ``mpl_configdir`` should be ``~/.config/matplotlib``,
but you can check where yours is with ``matplotlib.get_configdir()``, you may need to
create this directory. Note that a custom style sheet in ``mpl_configdir/stylelib``
Expand Down
0