8000 Add example for drawstyle · matplotlib/matplotlib@4bd9253 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4bd9253

Browse files
committed
Add example for drawstyle
1 parent 46c4585 commit 4bd9253

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

examples/lines_bars_and_markers/step_demo.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,24 @@
2727
plt.plot(x, y, 'C2o', alpha=0.5)
2828

2929
plt.legend(title='Parameter where:')
30+
plt.title('plt.step(where=...)')
31+
plt.show()
32+
33+
#############################################################################
34+
# The same behavior can be achieved by using the ``drawstyle`` parameter of
35+
# `.pyplot.plot`.
36+
37+
plt.plot(x, y + 2, drawstyle='steps', label='steps (=steps-pre)')
38+
plt.plot(x, y + 2, 'C0o', alpha=0.5)
39+
40+
plt.plot(x, y + 1, drawstyle='steps-mid', label='steps-mid')
41+
plt.plot(x, y + 1, 'C1o', alpha=0.5)
42+
43+
plt.plot(x, y, drawstyle='steps-post', label='steps-post')
44+
plt.plot(x, y, 'C2o', alpha=0.5)
45+
46+
plt.legend(title='Parameter drawstyle:')
47+
plt.title('plt.plot(drawstyle=...)')
3048
plt.show()
3149

3250
#############################################################################
@@ -42,3 +60,5 @@
4260
import matplotlib
4361
matplotlib.axes.Axes.step
4462
matplotlib.pyplot.step
63+
matplotlib.axes.Axes.plot
64+
matplotlib.pyplot.plot

lib/matplotlib/lines.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,9 @@ def set_markevery(self, every):
574574
be 0.5 multiplied by the display-coordinate-diagonal-distance
575575
along the line.
576576
577+
For examples see
578+
:doc:`/gallery/lines_bars_and_markers/markevery_demo`.
579+
577580
Notes
578581
-----
579582
Setting the markevery property will only show markers at actual data
@@ -1079,6 +1082,7 @@ def set_drawstyle(self, drawstyle):
10791082
- 'steps' is equal to 'steps-pre' and is maintained for
10801083
backward-compatibility.
10811084
1085+
For examples see :doc:`/gallery/lines_bars_and_markers/step_demo`.
10821086
"""
10831087
if drawstyle is None:
10841088
drawstyle = 'default'
@@ -1171,6 +1175,8 @@ def set_linestyle(self, ls):
11711175
11721176
where ``onoffseq`` is an even length tuple of on and off ink
11731177
in points. See also :meth:`set_dashes`.
1178+
1179+
For examples see :doc:`/gallery/lines_bars_and_markers/linestyles`.
11741180
"""
11751181
if isinstance(ls, str):
11761182
ds, ls = self._split_drawstyle_linestyle(ls)
@@ -1325,7 +1331,7 @@ def set_dashes(self, seq):
13251331
self.set_linestyle((0, seq))
13261332

13271333
def update_from(self, other):
1328-
"""Copy properties from other to self."""
1334+
"""Copy properties from *other* to self."""
13291335
Artist.update_from(self, other)
13301336
self._linestyle = other._linestyle
13311337
self._linewidth = other._linewidth
@@ -1402,6 +1408,7 @@ def set_dash_capstyle(self, s):
14021408
Parameters
14031409
----------
14041410
s : {'butt', 'round', 'projecting'}
1411+
For examples see :doc:`/gallery/lines_bars_and_markers/joinstyle`.
14051412
"""
14061413
s = s.lower()
14071414
cbook._check_in_list(self.validCap, s=s)
@@ -1416,6 +1423,7 @@ def set_solid_capstyle(self, s):
14161423
Parameters
14171424
----------
14181425
s : {'butt', 'round', 'projecting'}
1426+
For examples see :doc:`/gallery/lines_bars_and_markers/joinstyle`.
14191427
"""
14201428
s = s.lower()
14211429
cbook._check_in_list(self.validCap, s=s)

0 commit comments

Comments
 (0)
0