From 330f4b4c9ac089e31441a1a0cf3f0e983b3dd5b8 Mon Sep 17 00:00:00 2001 From: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Date: Thu, 16 May 2019 23:25:10 +0200 Subject: [PATCH] Backport PR #14228: DOC: fix parameters line in Axes.axis docstring --- lib/matplotlib/axes/_base.py | 2 +- lib/matplotlib/tests/test_axes.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/axes/_base.py b/lib/matplotlib/axes/_base.py index b37a083a8979..ae464e33c0a5 100644 --- a/lib/matplotlib/axes/_base.py +++ b/lib/matplotlib/axes/_base.py @@ -1607,7 +1607,7 @@ def axis(self, *args, **kwargs): Parameters ---------- - xmin, ymin, xmax, ymax : float, optional + xmin, xmax, ymin, ymax : float, optional The axis limits to be set. Either none or all of the limits must be given. diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index ffff5d1e194b..3ad2f259bcb2 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -6335,6 +6335,22 @@ def test_axis_bool_arguments(fig_test, fig_ref): fig_ref.add_subplot(212).axis("on") +def test_axis_extent_arg(): + fig, ax = plt.subplots() + xmin = 5 + xmax = 10 + ymin = 15 + ymax = 20 + extent = ax.axis([xmin, xmax, ymin, ymax]) + + # test that the docstring is correct + assert tuple(extent) == (xmin, xmax, ymin, ymax) + + # test that limits were set per the docstring + assert (xmin, xmax) == ax.get_xlim() + assert (ymin, ymax) == ax.get_ylim() + + def test_datetime_masked(): # make sure that all-masked data falls back to the viewlim # set in convert.axisinfo....