From bc497f04b59f0e665f71d2f2567cd7926d10f065 Mon Sep 17 00:00:00 2001 From: Marat K Date: Sun, 1 Mar 2020 21:04:27 +0100 Subject: [PATCH] Backport PR #16564: Fix documentation to change cycler instead of lines.color. --- tutorials/introductory/customizing.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tutorials/introductory/customizing.py b/tutorials/introductory/customizing.py index 39cb457e9c66..d44c77df1eb5 100644 --- a/tutorials/introductory/customizing.py +++ b/tutorials/introductory/customizing.py @@ -21,6 +21,7 @@ import numpy as np import matplotlib.pyplot as plt import matplotlib as mpl +from cycler import cycler plt.style.use('ggplot') data = np.random.randn(50) @@ -107,15 +108,22 @@ # the matplotlib package. rcParams can be modified directly, for example: mpl.rcParams['lines.linewidth'] = 2 -mpl.rcParams['lines.color'] = 'r' +mpl.rcParams['lines.linestyle'] = '--' plt.plot(data) +############################################################################### +# Note, that in order to change the usual `plot` color you have to change the +# *prop_cycle* property of *axes*: + +mpl.rcParams['axes.prop_cycle'] = cycler(color=['r', 'g', 'b', 'y']) +plt.plot(data) # first color is red + ############################################################################### # 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: -mpl.rc('lines', linewidth=4, color='g') +mpl.rc('lines', linewidth=4, linestyle='-.') plt.plot(data) ###############################################################################