Skip to content

Commit 799bca4

Browse files
anntzerMeeseeksDev[bot]
authored and
MeeseeksDev[bot]
committed
Backport PR #10662: Update docs on Axes.set_prop_cycle
1 parent 73340aa commit 799bca4

File tree

2 files changed

+53
-20
lines changed

2 files changed

+53
-20
lines changed

lib/matplotlib/axes/_base.py

+31-13
Original file line numberDiff line numberDiff line change
@@ -1177,40 +1177,58 @@ def _set_title_offset_trans(self, title_offset_points):
11771177

11781178
def set_prop_cycle(self, *args, **kwargs):
11791179
"""
1180-
Set the property cycle for any future plot commands on this Axes.
1180+
Set the property cycle of the Axes.
11811181
1182-
set_prop_cycle(arg)
1183-
set_prop_cycle(label, itr)
1184-
set_prop_cycle(label1=itr1[, label2=itr2[, ...]])
1182+
The property cycle controls the style properties such as color,
1183+
marker and linestyle of future plot commands. The style properties
1184+
of data already added to the Axes are not modified.
1185+
1186+
Call signatures::
1187+
1188+
set_prop_cycle(cycler)
1189+
set_prop_cycle(label, values)
1190+
set_prop_cycle(label=values[, label2=values2[, ...]])
11851191
11861192
Form 1 simply sets given `Cycler` object.
11871193
1188-
Form 2 creates and sets a `Cycler` from a label and an iterable.
1194+
Form 2 creates and sets a `Cycler` from a label and an iterable.
11891195
1190-
Form 3 composes and sets a `Cycler` as an inner product of the
1196+
Form 3 composes and sets a `Cycler` as an inner product of the
11911197
pairs of keyword arguments. In other words, all of the
11921198
iterables are cycled simultaneously, as if through zip().
11931199
11941200
Parameters
11951201
----------
1196-
arg : Cycler
1197-
Set the given Cycler.
1198-
Can also be `None` to reset to the cycle defined by the
1202+
cycler : Cycler
1203+
Set the given Cycler. *None* resets to the cycle defined by the
11991204
current style.
12001205
12011206
label : str
1202-
The property key. Must be a valid `Artist` property.
1207+
The property key. Must be a valid `.Artist` property.
12031208
For example, 'color' or 'linestyle'. Aliases are allowed,
12041209
such as 'c' for 'color' and 'lw' for 'linewidth'.
12051210
1206-
itr : iterable
1211+
values : iterable
12071212
Finite-length iterable of the property values. These values
12081213
are validated and will raise a ValueError if invalid.
12091214
1215+
Examples
1216+
--------
1217+
Setting the property cycle for a single property:
1218+
1219+
>>> ax.set_prop_cycle(color=['red', 'green', 'blue']) # or
1220+
>>> ax.set_prop_cycle('color', ['red', 'green', 'blue'])
1221+
1222+
Setting the property cycle for simultaneously cycling over multiple
1223+
properties (e.g. red circle, green plus, blue cross):
1224+
1225+
>>> ax.set_prop_cycle(color=['red', 'green', 'blue'],
1226+
... marker=['o', '+', 'x'])
1227+
12101228
See Also
12111229
--------
1212-
:func:`cycler` Convenience function for creating your
1213-
own cyclers.
1230+
matplotlib.rcsetup.cycler
1231+
Convenience function for creating your own cyclers.
12141232
12151233
"""
12161234
if args and kwargs:

lib/matplotlib/rcsetup.py

+22-7
Original file line numberDiff line numberDiff line change
@@ -722,9 +722,11 @@ def cycler(*args, **kwargs):
722722
Creates a :class:`cycler.Cycler` object much like :func:`cycler.cycler`,
723723
but includes input validation.
724724
725-
cycler(arg)
726-
cycler(label, itr)
727-
cycler(label1=itr1[, label2=itr2[, ...]])
725+
Call signatures::
726+
727+
cycler(cycler)
728+
cycler(label, values)
729+
cycler(label=values[, label2=values2[, ...]])
728730
729731
Form 1 simply copies a given `Cycler` object.
730732
@@ -736,15 +738,15 @@ def cycler(*args, **kwargs):
736738
737739
Parameters
738740
----------
739-
arg : Cycler
741+
cycler : Cycler
740742
Copy constructor for Cycler.
741743
742-
label : name
743-
The property key. Must be a valid `Artist` property.
744+
label : str
745+
The property key. Must be a valid `.Artist` property.
744746
For example, 'color' or 'linestyle'. Aliases are allowed,
745747
such as 'c' for 'color' and 'lw' for 'linewidth'.
746748
747-
itr : iterable
749+
values : iterable
748750
Finite-length iterable of the property values. These values
749751
are validated and will raise a ValueError if invalid.
750752
@@ -753,6 +755,19 @@ def cycler(*args, **kwargs):
753755
cycler : Cycler
754756
New :class:`cycler.Cycler` for the given properties
755757
758+
Examples
759+
--------
760+
Creating a cycler for a single property:
761+
762+
>>> c = cycler(color=['red', 'green', 'blue']) # or
763+
>>> c = cycler('color', ['red', 'green', 'blue'])
764+
765+
Creating a cycler for simultaneously cycling over multiple properties
766+
(e.g. red circle, green plus, blue cross):
767+
768+
>>> c = cycler(color=['red', 'green', 'blue'],
769+
... marker=['o', '+', 'x'])
770+
756771
"""
757772
if args and kwargs:
758773
raise TypeError("cycler() can only accept positional OR keyword "

0 commit comments

Comments
 (0)