Skip to content

Commit 77b85ad

Browse files
committed
Add test
1 parent 0482fff commit 77b85ad

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

lib/matplotlib/tests/test_axes.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import matplotlib.font_manager as mfont_manager
2424
import matplotlib.markers as mmarkers
2525
import matplotlib.patches as mpatches
26+
import matplotlib.path as mpath
2627
import matplotlib.pyplot as plt
2728
import matplotlib.ticker as mticker
2829
import matplotlib.transforms as mtransforms
@@ -7271,3 +7272,24 @@ def test_clim():
72717272
clim = (7, 8)
72727273
norm = plot_method([[0, 1], [2, 3]], clim=clim).norm
72737274
assert (norm.vmin, norm.vmax) == clim
7275+
7276+
7277+
def test_bezier_autoscale():
7278+
# Check that bezier curves autoscale to their curves, and not their
7279+
# control points
7280+
verts = [[-1, 0],
7281+
[0, -1],
7282+
[1, 0],
7283+
[1, 0]]
7284+
codes = [mpath.Path.MOVETO,
7285+
mpath.Path.CURVE3,
7286+
mpath.Path.CURVE3,
7287+
mpath.Path.CLOSEPOLY]
7288+
p = mpath.Path(verts, codes)
7289+
7290+
fig, ax = plt.subplots()
7291+
ax.add_patch(mpatches.PathPatch(p))
7292+
ax.autoscale()
7293+
# Bottom ylim should be at the edge of the curve (-0.5), and not include
7294+
# the control point (at -1)
7295+
assert ax.get_ylim()[0] == -0.5

0 commit comments

Comments
 (0)