Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3c159eb

Browse files
committed
improve-matplotlibrc-tutorial: make path/URL option clearer
1 parent 4729585 commit 3c159eb

1 file changed

Lines changed: 24 additions & 15 deletions

File tree

tutorials/introductory/customizing.py

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,10 @@
3535
# -----------------------
3636
#
3737
# You can create custom styles and use them by calling `.style.use` with
38-
# the path or URL to the style sheet. Additionally, if you add your
39-
# ``<style-name>.mplstyle`` file to ``mpl_configdir/stylelib``, you can reuse
40-
# your custom style sheet with a call to ``style.use(<style-name>)``. By
41-
# default ``mpl_configdir`` should be ``~/.config/matplotlib``, but you can
42-
# check where yours is with `matplotlib.get_configdir()`; you may need to
43-
# create this directory. You also can change the directory where Matplotlib
44-
# looks for the stylelib/ folder by setting the :envvar:`MPLCONFIGDIR`
45-
# environment variable, see :ref:`locating-matplotlib-config-dir`.
46-
#
47-
# Note that a custom style sheet in ``mpl_configdir/stylelib`` will override a
48-
# style sheet defined by Matplotlib if the styles have the same name.
38+
# the path or URL to the style sheet.
4939
#
5040
# For example, you might want to create
51-
# ``mpl_configdir/stylelib/presentation.mplstyle`` with the following::
41+
# ``../images/presentation.mplstyle`` with the following::
5242
#
5343
# axes.titlesize : 24
5444
# axes.labelsize : 20
@@ -61,7 +51,25 @@
6151
# good in a presentation, you can just add::
6252
#
6353
# >>> import matplotlib.pyplot as plt
64-
# >>> plt.style.use('presentation')
54+
# >>> plt.style.use('../images/presentation.mplstyle')
55+
#
56+
# Alternatively, you can load your custom style sheet with a call to
57+
# ``style.use(<style-name>)`` by placing your ``<style-name>.mplstyle`` file
58+
# into ``mpl_configdir/stylelib``. By default ``mpl_configdir`` should be
59+
# ``~/.config/matplotlib``, but you can check where yours is with
60+
# `matplotlib.get_configdir()`; you may need to create this directory. You also
61+
# can change the directory where Matplotlib looks for the stylelib/ folder by
62+
# setting the :envvar:`MPLCONFIGDIR` environment variable, see
63+
# :ref:`locating-matplotlib-config-dir`.
64+
#
65+
# Note that a custom style sheet in ``mpl_configdir/stylelib`` will override a
66+
# style sheet defined by Matplotlib if the styles have the same name.
67+
#
68+
# Once your ``<style-name>.mplstyle`` file is in the appropriate
69+
# ``mpl_configdir`` you can specify your style with::
70+
#
71+
# >>> import matplotlib.pyplot as plt
72+
# >>> plt.style.use('<style-name>')
6573
#
6674
#
6775
# Composing styles
@@ -142,8 +150,9 @@
142150
# kinds of properties, which we call 'rc settings' or 'rc parameters'. You can
143151
# control the defaults of almost every property in Matplotlib: figure size and
144152
# DPI, line width, color and style, axes, axis and grid properties, text and
145-
# font properties and so on. Matplotlib looks for :file:`matplotlibrc` in four
146-
# locations, in the following order:
153+
# font properties and so on. When a URL or path is not specified with a call to
154+
# `style.use('<path>/<style-name>.mplstyle')`, Matplotlib looks for
155+
# :file:`matplotlibrc` in four locations, in the following order:
147156
#
148157
# 1. :file:`matplotlibrc` in the current working directory, usually used for
149158
# specific customizations that you do not want to apply elsewhere.

0 commit comments

Comments
 (0)