diff --git a/lib/matplotlib/axes/_base.py b/lib/matplotlib/axes/_base.py index 2e519a74c18e..6d34272b96fc 100644 --- a/lib/matplotlib/axes/_base.py +++ b/lib/matplotlib/axes/_base.py @@ -1410,12 +1410,10 @@ def get_data_ratio(self): ----- This method is intended to be overridden by new projection types. """ - trf_xmin, trf_xmax = map( - self.xaxis.get_transform().transform, self.get_xbound()) - trf_ymin, trf_ymax = map( - self.yaxis.get_transform().transform, self.get_ybound()) - xsize = max(abs(trf_xmax - trf_xmin), 1e-30) - ysize = max(abs(trf_ymax - trf_ymin), 1e-30) + txmin, txmax = self.xaxis.get_transform().transform(self.get_xbound()) + tymin, tymax = self.yaxis.get_transform().transform(self.get_ybound()) + xsize = max(abs(txmax - txmin), 1e-30) + ysize = max(abs(tymax - tymin), 1e-30) return ysize / xsize @cbook.deprecated("3.2") @@ -1492,8 +1490,8 @@ def apply_aspect(self, position=None): x_trf = self.xaxis.get_transform() y_trf = self.yaxis.get_transform() - xmin, xmax = map(x_trf.transform, self.get_xbound()) - ymin, ymax = map(y_trf.transform, self.get_ybound()) + xmin, xmax = x_trf.transform(self.get_xbound()) + ymin, ymax = y_trf.transform(self.get_ybound()) xsize = max(abs(xmax - xmin), 1e-30) ysize = max(abs(ymax - ymin), 1e-30) @@ -1507,8 +1505,8 @@ def apply_aspect(self, position=None): return dL = self.dataLim - x0, x1 = map(x_trf.inverted().transform, dL.intervalx) - y0, y1 = map(y_trf.inverted().transform, dL.intervaly) + x0, x1 = x_trf.transform(dL.intervalx) + y0, y1 = y_trf.transform(dL.intervaly) xr = 1.05 * (x1 - x0) yr = 1.05 * (y1 - y0) @@ -1544,12 +1542,12 @@ def apply_aspect(self, position=None): yc = 0.5 * (ymin + ymax) y0 = yc - Ysize / 2.0 y1 = yc + Ysize / 2.0 - self.set_ybound(*map(y_trf.inverted().transform, (y0, y1))) + self.set_ybound(y_trf.inverted().transform([y0, y1])) else: xc = 0.5 * (xmin + xmax) x0 = xc - Xsize / 2.0 x1 = xc + Xsize / 2.0 - self.set_xbound(*map(x_trf.inverted().transform, (x0, x1))) + self.set_xbound(x_trf.inverted().transform([x0, x1])) def axis(self, *args, emit=True, **kwargs): """ diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index f7036342d720..abe33dcf0491 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -6554,9 +6554,10 @@ def test_aspect_nonlinear_adjustable_datalim(): ax = fig.add_axes([.1, .1, .8, .8]) # Square. ax.plot([.4, .6], [.4, .6]) # Set minpos to keep logit happy. - ax.set(xscale="log", xlim=(1, 10), - yscale="logit", ylim=(1/11, 1/1001), + ax.set(xscale="log", xlim=(1, 100), + yscale="logit", ylim=(1 / 101, 1 / 11), aspect=1, adjustable="datalim") ax.margins(0) ax.apply_aspect() - assert ax.get_xlim() == pytest.approx(np.array([1/10, 10]) * np.sqrt(10)) + assert ax.get_xlim() == pytest.approx([1*10**(1/2), 100/10**(1/2)]) + assert ax.get_ylim() == (1 / 101, 1 / 11)
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: