Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit aa905ac

Browse files
committed
feat: rename levels to stairs
1 parent 4a111ce commit aa905ac

12 files changed

Lines changed: 62 additions & 62 deletions

File tree

doc/api/artist_api.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
``matplotlib.artist``
55
*********************
66

7-
.. inheritance-diagram:: matplotlib.axes._axes.Axes matplotlib.axes._base._AxesBase matplotlib.axis.Axis matplotlib.axis.Tick matplotlib.axis.XAxis matplotlib.axis.XTick matplotlib.axis.YAxis matplotlib.axis.YTick matplotlib.collections.AsteriskPolygonCollection matplotlib.collections.BrokenBarHCollection matplotlib.collections.CircleCollection matplotlib.collections.Collection matplotlib.collections.EllipseCollection matplotlib.collections.EventCollection matplotlib.collections.LineCollection matplotlib.collections.PatchCollection matplotlib.collections.PathCollection matplotlib.collections.PolyCollection matplotlib.collections.QuadMesh matplotlib.collections.RegularPolyCollection matplotlib.collections.StarPolygonCollection matplotlib.collections.TriMesh matplotlib.collections._CollectionWithSizes matplotlib.contour.ClabelText matplotlib.figure.Figure matplotlib.image.AxesImage matplotlib.image.BboxImage matplotlib.image.FigureImage matplotlib.image.NonUniformImage matplotlib.image.PcolorImage matplotlib.image._ImageBase matplotlib.legend.Legend matplotlib.lines.Line2D matplotlib.offsetbox.AnchoredOffsetbox matplotlib.offsetbox.AnchoredText matplotlib.offsetbox.AnnotationBbox matplotlib.offsetbox.AuxTransformBox matplotlib.offsetbox.DrawingArea matplotlib.offsetbox.HPacker matplotlib.offsetbox.OffsetBox matplotlib.offsetbox.OffsetImage matplotlib.offsetbox.PackerBase matplotlib.offsetbox.PaddedBox matplotlib.offsetbox.TextArea matplotlib.offsetbox.VPacker matplotlib.patches.Arc matplotlib.patches.Arrow matplotlib.patches.Circle matplotlib.patches.CirclePolygon matplotlib.patches.ConnectionPatch matplotlib.patches.Ellipse matplotlib.patches.FancyArrow matplotlib.patches.FancyArrowPatch matplotlib.patches.FancyBboxPatch matplotlib.patches.Patch matplotlib.patches.PathPatch matplotlib.patches.LevelsPatch matplotlib.patches.Polygon matplotlib.patches.Rectangle matplotlib.patches.RegularPolygon matplotlib.patches.Shadow matplotlib.patches.Wedge matplotlib.projections.geo.AitoffAxes matplotlib.projections.geo.GeoAxes matplotlib.projections.geo.HammerAxes matplotlib.projections.geo.LambertAxes matplotlib.projections.geo.MollweideAxes matplotlib.projections.polar.PolarAxes matplotlib.quiver.Barbs matplotlib.quiver.Quiver matplotlib.quiver.QuiverKey matplotlib.spines.Spine matplotlib.table.Cell matplotlib.table.CustomCell matplotlib.table.Table matplotlib.text.Annotation matplotlib.text.Text
7+
.. inheritance-diagram:: matplotlib.axes._axes.Axes matplotlib.axes._base._AxesBase matplotlib.axis.Axis matplotlib.axis.Tick matplotlib.axis.XAxis matplotlib.axis.XTick matplotlib.axis.YAxis matplotlib.axis.YTick matplotlib.collections.AsteriskPolygonCollection matplotlib.collections.BrokenBarHCollection matplotlib.collections.CircleCollection matplotlib.collections.Collection matplotlib.collections.EllipseCollection matplotlib.collections.EventCollection matplotlib.collections.LineCollection matplotlib.collections.PatchCollection matplotlib.collections.PathCollection matplotlib.collections.PolyCollection matplotlib.collections.QuadMesh matplotlib.collections.RegularPolyCollection matplotlib.collections.StarPolygonCollection matplotlib.collections.TriMesh matplotlib.collections._CollectionWithSizes matplotlib.contour.ClabelText matplotlib.figure.Figure matplotlib.image.AxesImage matplotlib.image.BboxImage matplotlib.image.FigureImage matplotlib.image.NonUniformImage matplotlib.image.PcolorImage matplotlib.image._ImageBase matplotlib.legend.Legend matplotlib.lines.Line2D matplotlib.offsetbox.AnchoredOffsetbox matplotlib.offsetbox.AnchoredText matplotlib.offsetbox.AnnotationBbox matplotlib.offsetbox.AuxTransformBox matplotlib.offsetbox.DrawingArea matplotlib.offsetbox.HPacker matplotlib.offsetbox.OffsetBox matplotlib.offsetbox.OffsetImage matplotlib.offsetbox.PackerBase matplotlib.offsetbox.PaddedBox matplotlib.offsetbox.TextArea matplotlib.offsetbox.VPacker matplotlib.patches.Arc matplotlib.patches.Arrow matplotlib.patches.Circle matplotlib.patches.CirclePolygon matplotlib.patches.ConnectionPatch matplotlib.patches.Ellipse matplotlib.patches.FancyArrow matplotlib.patches.FancyArrowPatch matplotlib.patches.FancyBboxPatch matplotlib.patches.Patch matplotlib.patches.PathPatch matplotlib.patches.StepPatch matplotlib.patches.Polygon matplotlib.patches.Rectangle matplotlib.patches.RegularPolygon matplotlib.patches.Shadow matplotlib.patches.Wedge matplotlib.projections.geo.AitoffAxes matplotlib.projections.geo.GeoAxes matplotlib.projections.geo.HammerAxes matplotlib.projections.geo.LambertAxes matplotlib.projections.geo.MollweideAxes matplotlib.projections.polar.PolarAxes matplotlib.quiver.Barbs matplotlib.quiver.Quiver matplotlib.quiver.QuiverKey matplotlib.spines.Spine matplotlib.table.Cell matplotlib.table.CustomCell matplotlib.table.Table matplotlib.text.Annotation matplotlib.text.Text
88
:parts: 1
99
:private-bases:
1010

doc/api/patches_api.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Classes
2929
FancyBboxPatch
3030
Patch
3131
PathPatch
32-
LevelsPatch
32+
StepPatch
3333
Polygon
3434
Rectangle
3535
RegularPolygon

doc/users/next_whats_new/steppatch_and_histline.rst renamed to doc/users/next_whats_new/steppatch_and_stairs.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
New `~.matplotlib.patches.LevelsPatch` artist and a `.pyplot.levels` method
2-
---------------------------------------------------------------------------
1+
New `~.matplotlib.patches.StepPatch` artist and a `.pyplot.stairs` method
2+
-------------------------------------------------------------------------
33
These take inputs of asymmetric lengths with y-like values and
44
x-like edges, between which the values lie.
55

@@ -14,9 +14,9 @@ x-like edges, between which the values lie.
1414

1515
fig, ax = plt.subplots(constrained_layout=True)
1616

17-
ax.levels(h, bins)
17+
ax.stairs(h, bins)
1818

1919
plt.show()
2020

21-
See :doc:`/gallery/lines_bars_and_markers/levels_demo`
21+
See :doc:`/gallery/lines_bars_and_markers/stairs_demo`
2222
for examples.

examples/lines_bars_and_markers/levels_demo.py renamed to examples/lines_bars_and_markers/stairs_demo.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,41 @@
33
Histline Demo
44
=============
55
6-
This example demonstrates the use of `~.matplotlib.pyplot.levels`
6+
This example demonstrates the use of `~.matplotlib.pyplot.stairs`
77
for histogram and histogram-like data visualization and an associated
8-
underlying `.LevelsPatch` artist, which is
8+
underlying `.StepPatch` artist, which is
99
a contrained version of `.PathPatch` specified by its bins and edges.
1010
"""
1111

1212
import numpy as np
1313
import matplotlib.pyplot as plt
14-
from matplotlib.patches import LevelsPatch
14+
from matplotlib.patches import StepPatch
1515

1616
np.random.seed(0)
1717
h, bins = np.histogram(np.random.normal(5, 3, 5000),
1818
bins=np.linspace(0, 10, 20))
1919

2020
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')
2424
axs[0].set_title("Step Histograms")
2525

26-
axs[1].levels(np.arange(1, 6, 1), fill=True,
26+
axs[1].stairs(np.arange(1, 6, 1), fill=True,
2727
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),
2929
orientation='horizontal', hatch='//',
3030
label='Hatched histogram\nw/ horizontal orientation')
3131
axs[1].set_title("Filled histogram")
3232

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'))
3737
axs[2].add_patch(patch)
3838
axs[2].set_xlim(0, 7)
3939
axs[2].set_ylim(-1, 5)
40-
axs[2].set_title("LevelsPatch artist")
40+
axs[2].set_title("StepPatch artist")
4141

4242
for ax in axs:
4343
ax.legend()
@@ -55,6 +55,6 @@
5555
# in this example:
5656

5757
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

lib/matplotlib/axes/_axes.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6872,7 +6872,7 @@ def hist(self, x, bins=None, range=None, density=False, weights=None,
68726872
return tops, bins, cbook.silent_list(patch_type, patches)
68736873

68746874
@_preprocess_data()
6875-
def levels(self, values, edges=None, *,
6875+
def stairs(self, values, edges=None, *,
68766876
orientation='vertical', baseline=0, fill=False, **kwargs):
68776877
"""
68786878
A histogram-like line or filled plot.
@@ -6896,12 +6896,12 @@ def levels(self, values, edges=None, *,
68966896
68976897
Returns
68986898
-------
6899-
LevelsPatch : `matplotlib.patches.LevelsPatch`
6899+
StepPatch : `matplotlib.patches.StepPatch`
69006900
69016901
Other Parameters
69026902
----------------
69036903
**kwargs
6904-
`~matplotlib.patches.LevelsPatch` properties
6904+
`~matplotlib.patches.StepPatch` properties
69056905
69066906
"""
69076907

@@ -6918,12 +6918,12 @@ def levels(self, values, edges=None, *,
69186918
if edges is None:
69196919
edges = np.arange(len(values) + 1)
69206920

6921-
patch = mpatches.LevelsPatch(values,
6922-
edges,
6923-
baseline=baseline,
6924-
orientation=orientation,
6925-
fill=fill,
6926-
**kwargs)
6921+
patch = mpatches.StepPatch(values,
6922+
edges,
6923+
baseline=baseline,
6924+
orientation=orientation,
6925+
fill=fill,
6926+
**kwargs)
69276927
self.add_patch(patch)
69286928
if baseline is None:
69296929
baseline = 0

lib/matplotlib/legend.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
from matplotlib.font_manager import FontProperties
3535
from matplotlib.lines import Line2D
3636
from matplotlib.patches import (Patch, Rectangle, Shadow, FancyBboxPatch,
37-
LevelsPatch)
37+
StepPatch)
3838
from matplotlib.collections import (LineCollection, RegularPolyCollection,
3939
CircleCollection, PathCollection,
4040
PolyCollection)
@@ -624,7 +624,7 @@ def draw(self, renderer):
624624
ErrorbarContainer: legend_handler.HandlerErrorbar(),
625625
Line2D: legend_handler.HandlerLine2D(),
626626
Patch: legend_handler.HandlerPatch(),
627-
LevelsPatch: legend_handler.HandlerLevelsPatch(),
627+
StepPatch: legend_handler.HandlerStepPatch(),
628628
LineCollection: legend_handler.HandlerLineCollection(),
629629
RegularPolyCollection: legend_handler.HandlerRegularPolyCollection(),
630630
CircleCollection: legend_handler.HandlerCircleCollection(),

lib/matplotlib/legend_handler.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,9 @@ def create_artists(self, legend, orig_handle,
302302
return [p]
303303

304304

305-
class HandlerLevelsPatch(HandlerBase):
305+
class HandlerStepPatch(HandlerBase):
306306
"""
307-
Handler for `~.matplotlib.patches.LevelsPatch` instances.
307+
Handler for `~.matplotlib.patches.StepPatch` instances.
308308
"""
309309
def __init__(self, **kw):
310310
"""
@@ -319,7 +319,7 @@ def _create_patch(self, legend, orig_handle,
319319
width=width, height=height)
320320
return p
321321

322-
# Unfilled LevelsPatch should show as a line
322+
# Unfilled StepPatch should show as a line
323323
def _create_line(self, legend, orig_handle,
324324
xdescent, ydescent, width, height, fontsize):
325325

lib/matplotlib/patches.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -989,8 +989,8 @@ def set_path(self, path):
989989
self._path = path
990990

991991

992-
class LevelsPatch(PathPatch):
993-
"""An unclosed levels path patch."""
992+
class StepPatch(PathPatch):
993+
"""An unclosed step path patch."""
994994

995995
@docstring.dedent_interpd
996996
def __init__(self, values, edges, *,

lib/matplotlib/pyplot.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2778,11 +2778,11 @@ def hist(
27782778

27792779

27802780
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
2781-
@_copy_docstring_and_deprecators(Axes.levels)
2782-
def levels(
2781+
@_copy_docstring_and_deprecators(Axes.stairs)
2782+
def stairs(
27832783
values, edges=None, *, orientation='vertical', baseline=0,
27842784
fill=False, data=None, **kwargs):
2785-
return gca().levels(
2785+
return gca().stairs(
27862786
values, edges=edges, orientation=orientation,
27872787
baseline=baseline, fill=fill,
27882788
**({"data": data} if data is not None else {}), **kwargs)

lib/matplotlib/tests/baseline_images/test_axes/test_levels_options.png renamed to lib/matplotlib/tests/baseline_images/test_axes/test_stairs_options.png

File renamed without changes.

0 commit comments

Comments
 (0)