|
18 | 18 | y = np.sin(x / 2) |
19 | 19 |
|
20 | 20 | plt.step(x, y + 2, label='pre (default)') |
21 | | -plt.plot(x, y + 2, 'C0o', alpha=0.5) |
| 21 | +plt.plot(x, y + 2, 'o--', color='grey', alpha=0.3) |
22 | 22 |
|
23 | 23 | plt.step(x, y + 1, where='mid', label='mid') |
24 | | -plt.plot(x, y + 1, 'C1o', alpha=0.5) |
| 24 | +plt.plot(x, y + 1, 'o--', color='grey', alpha=0.3) |
25 | 25 |
|
26 | 26 | plt.step(x, y, where='post', label='post') |
27 | | -plt.plot(x, y, 'C2o', alpha=0.5) |
| 27 | +plt.plot(x, y, 'o--', color='grey', alpha=0.3) |
28 | 28 |
|
| 29 | +plt.grid(axis='x', color='0.95') |
29 | 30 | plt.legend(title='Parameter where:') |
| 31 | +plt.title('plt.step(where=...)') |
| 32 | +plt.show() |
| 33 | + |
| 34 | +############################################################################# |
| 35 | +# The same behavior can be achieved by using the ``drawstyle`` parameter of |
| 36 | +# `.pyplot.plot`. |
| 37 | + |
| 38 | +plt.plot(x, y + 2, drawstyle='steps', label='steps (=steps-pre)') |
| 39 | +plt.plot(x, y + 2, 'o--', color='grey', alpha=0.3) |
| 40 | + |
| 41 | +plt.plot(x, y + 1, drawstyle='steps-mid', label='steps-mid') |
| 42 | +plt.plot(x, y + 1, 'o--', color='grey', alpha=0.3) |
| 43 | + |
| 44 | +plt.plot(x, y, drawstyle='steps-post', label='steps-post') |
| 45 | +plt.plot(x, y, 'o--', color='grey', alpha=0.3) |
| 46 | + |
| 47 | +plt.grid(axis='x', color='0.95') |
| 48 | +plt.legend(title='Parameter drawstyle:') |
| 49 | +plt.title('plt.plot(drawstyle=...)') |
30 | 50 | plt.show() |
31 | 51 |
|
32 | 52 | ############################################################################# |
|
42 | 62 | import matplotlib |
43 | 63 | matplotlib.axes.Axes.step |
44 | 64 | matplotlib.pyplot.step |
| 65 | +matplotlib.axes.Axes.plot |
| 66 | +matplotlib.pyplot.plot |
0 commit comments