|
3 | 3 | Histline Demo |
4 | 4 | ============= |
5 | 5 |
|
6 | | -This example demonstrates the use of `~.matplotlib.pyplot.levels` |
| 6 | +This example demonstrates the use of `~.matplotlib.pyplot.stairs` |
7 | 7 | for histogram and histogram-like data visualization and an associated |
8 | | -underlying `.LevelsPatch` artist, which is |
| 8 | +underlying `.StepPatch` artist, which is |
9 | 9 | a contrained version of `.PathPatch` specified by its bins and edges. |
10 | 10 | """ |
11 | 11 |
|
12 | 12 | import numpy as np |
13 | 13 | import matplotlib.pyplot as plt |
14 | | -from matplotlib.patches import LevelsPatch |
| 14 | +from matplotlib.patches import StepPatch |
15 | 15 |
|
16 | 16 | np.random.seed(0) |
17 | 17 | h, bins = np.histogram(np.random.normal(5, 3, 5000), |
18 | 18 | bins=np.linspace(0, 10, 20)) |
19 | 19 |
|
20 | 20 | fig, axs = plt.subplots(3, 1, figsize=(7, 15)) |
21 | | -axs[0].levels(h, bins, label='Simple histogram') |
22 | | -axs[0].levels(h, bins+5, baseline=50, label='--//-- w/ modified baseline') |
23 | | -axs[0].levels(h, bins+10, baseline=None, label='--//-- w/ no edges') |
| 21 | +axs[0].stairs(h, bins, label='Simple histogram') |
| 22 | +axs[0].stairs(h, bins+5, baseline=50, label='--//-- w/ modified baseline') |
| 23 | +axs[0].stairs(h, bins+10, baseline=None, label='--//-- w/ no edges') |
24 | 24 | axs[0].set_title("Step Histograms") |
25 | 25 |
|
26 | | -axs[1].levels(np.arange(1, 6, 1), fill=True, |
| 26 | +axs[1].stairs(np.arange(1, 6, 1), fill=True, |
27 | 27 | label='Filled histogram\nw/ automatatic edges') |
28 | | -axs[1].levels(np.arange(1, 6, 1)*0.3, np.arange(2, 8, 1), |
| 28 | +axs[1].stairs(np.arange(1, 6, 1)*0.3, np.arange(2, 8, 1), |
29 | 29 | orientation='horizontal', hatch='//', |
30 | 30 | label='Hatched histogram\nw/ horizontal orientation') |
31 | 31 | axs[1].set_title("Filled histogram") |
32 | 32 |
|
33 | | -patch = LevelsPatch(values=[1, 2, 3, 2, 1], |
34 | | - edges=range(1, 7), |
35 | | - label=('Patch derived underlying object\n' |
36 | | - 'with default edge/facecolor behaviour')) |
| 33 | +patch = StepPatch(values=[1, 2, 3, 2, 1], |
| 34 | + edges=range(1, 7), |
| 35 | + label=('Patch derived underlying object\n' |
| 36 | + 'with default edge/facecolor behaviour')) |
37 | 37 | axs[2].add_patch(patch) |
38 | 38 | axs[2].set_xlim(0, 7) |
39 | 39 | axs[2].set_ylim(-1, 5) |
40 | | -axs[2].set_title("LevelsPatch artist") |
| 40 | +axs[2].set_title("StepPatch artist") |
41 | 41 |
|
42 | 42 | for ax in axs: |
43 | 43 | ax.legend() |
|
55 | 55 | # in this example: |
56 | 56 |
|
57 | 57 | import matplotlib |
58 | | -matplotlib.axes.Axes.levels |
59 | | -matplotlib.pyplot.levels |
60 | | -matplotlib.patches.LevelsPatch |
| 58 | +matplotlib.axes.Axes.stairs |
| 59 | +matplotlib.pyplot.stairs |
| 60 | +matplotlib.patches.StepPatch |
0 commit comments