Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e92117c

Browse filesBrowse files
authored
Merge pull request #10662 from timhoffm/axes-doc-prop-cycle
Update docs on Axes.set_prop_cycle
2 parents e3e387a + 962a2d7 commit e92117c
Copy full SHA for e92117c

File tree

Expand file treeCollapse file tree

2 files changed

+53
-20
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+53
-20
lines changed

‎lib/matplotlib/axes/_base.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_base.py
+31-13Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,40 +1152,58 @@ def _set_title_offset_trans(self, title_offset_points):
11521152

11531153
def set_prop_cycle(self, *args, **kwargs):
11541154
"""
1155-
Set the property cycle for any future plot commands on this Axes.
1155+
Set the property cycle of the Axes.
11561156
1157-
set_prop_cycle(arg)
1158-
set_prop_cycle(label, itr)
1159-
set_prop_cycle(label1=itr1[, label2=itr2[, ...]])
1157+
The property cycle controls the style properties such as color,
1158+
marker and linestyle of future plot commands. The style properties
1159+
of data already added to the Axes are not modified.
1160+
1161+
Call signatures::
1162+
1163+
set_prop_cycle(cycler)
1164+
set_prop_cycle(label, values)
1165+
set_prop_cycle(label=values[, label2=values2[, ...]])
11601166
11611167
Form 1 simply sets given `Cycler` object.
11621168
1163-
Form 2 creates and sets a `Cycler` from a label and an iterable.
1169+
Form 2 creates and sets a `Cycler` from a label and an iterable.
11641170
1165-
Form 3 composes and sets a `Cycler` as an inner product of the
1171+
Form 3 composes and sets a `Cycler` as an inner product of the
11661172
pairs of keyword arguments. In other words, all of the
11671173
iterables are cycled simultaneously, as if through zip().
11681174
11691175
Parameters
11701176
----------
1171-
arg : Cycler
1172-
Set the given Cycler.
1173-
Can also be `None` to reset to the cycle defined by the
1177+
cycler : Cycler
1178+
Set the given Cycler. *None* resets to the cycle defined by the
11741179
current style.
11751180
11761181
label : str
1177-
The property key. Must be a valid `Artist` property.
1182+
The property key. Must be a valid `.Artist` property.
11781183
For example, 'color' or 'linestyle'. Aliases are allowed,
11791184
such as 'c' for 'color' and 'lw' for 'linewidth'.
11801185
1181-
itr : iterable
1186+
values : iterable
11821187
Finite-length iterable of the property values. These values
11831188
are validated and will raise a ValueError if invalid.
11841189
1190+
Examples
1191+
--------
1192+
Setting the property cycle for a single property:
1193+
1194+
>>> ax.set_prop_cycle(color=['red', 'green', 'blue']) # or
1195+
>>> ax.set_prop_cycle('color', ['red', 'green', 'blue'])
1196+
1197+
Setting the property cycle for simultaneously cycling over multiple
1198+
properties (e.g. red circle, green plus, blue cross):
1199+
1200+
>>> ax.set_prop_cycle(color=['red', 'green', 'blue'],
1201+
... marker=['o', '+', 'x'])
1202+
11851203
See Also
11861204
--------
1187-
:func:`cycler` Convenience function for creating your
1188-
own cyclers.
1205+
matplotlib.rcsetup.cycler
1206+
Convenience function for creating your own cyclers.
11891207
11901208
"""
11911209
if args and kwargs:

‎lib/matplotlib/rcsetup.py

Copy file name to clipboardExpand all lines: lib/matplotlib/rcsetup.py
+22-7Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -747,9 +747,11 @@ def cycler(*args, **kwargs):
747747
Creates a :class:`cycler.Cycler` object much like :func:`cycler.cycler`,
748748
but includes input validation.
749749
750-
cycler(arg)
751-
cycler(label, itr)
752-
cycler(label1=itr1[, label2=itr2[, ...]])
750+
Call signatures::
751+
752+
cycler(cycler)
753+
cycler(label, values)
754+
cycler(label=values[, label2=values2[, ...]])
753755
754756
Form 1 simply copies a given `Cycler` object.
755757
@@ -761,15 +763,15 @@ def cycler(*args, **kwargs):
761763
762764
Parameters
763765
----------
764-
arg : Cycler
766+
cycler : Cycler
765767
Copy constructor for Cycler.
766768
767-
label : name
768-
The property key. Must be a valid `Artist` property.
769+
label : str
770+
The property key. Must be a valid `.Artist` property.
769771
For example, 'color' or 'linestyle'. Aliases are allowed,
770772
such as 'c' for 'color' and 'lw' for 'linewidth'.
771773
772-
itr : iterable
774+
values : iterable
773775
Finite-length iterable of the property values. These values
774776
are validated and will raise a ValueError if invalid.
775777
@@ -778,6 +780,19 @@ def cycler(*args, **kwargs):
778780
cycler : Cycler
779781
New :class:`cycler.Cycler` for the given properties
780782
783+
Examples
784+
--------
785+
Creating a cycler for a single property:
786+
787+
>>> c = cycler(color=['red', 'green', 'blue']) # or
788+
>>> c = cycler('color', ['red', 'green', 'blue'])
789+
790+
Creating a cycler for simultaneously cycling over multiple properties
791+
(e.g. red circle, green plus, blue cross):
792+
793+
>>> c = cycler(color=['red', 'green', 'blue'],
794+
... marker=['o', '+', 'x'])
795+
781796
"""
782797
if args and kwargs:
783798
raise TypeError("cycler() can only accept positional OR keyword "

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.