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

Skip to content

Commit d3db965

Browse files
committed
transform() is vectorized.
1 parent 418a1ad commit d3db965

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

lib/matplotlib/axes/_base.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,12 +1410,10 @@ def get_data_ratio(self):
14101410
-----
14111411
This method is intended to be overridden by new projection types.
14121412
"""
1413-
trf_xmin, trf_xmax = map(
1414-
self.xaxis.get_transform().transform, self.get_xbound())
1415-
trf_ymin, trf_ymax = map(
1416-
self.yaxis.get_transform().transform, self.get_ybound())
1417-
xsize = max(abs(trf_xmax - trf_xmin), 1e-30)
1418-
ysize = max(abs(trf_ymax - trf_ymin), 1e-30)
1413+
txmin, txmax = self.xaxis.get_transform().transform(self.get_xbound())
1414+
tymin, tymax = self.yaxis.get_transform().transform(self.get_ybound())
1415+
xsize = max(abs(txmax - txmin), 1e-30)
1416+
ysize = max(abs(tymax - tymin), 1e-30)
14191417
return ysize / xsize
14201418

14211419
@cbook.deprecated("3.2")
@@ -1492,8 +1490,8 @@ def apply_aspect(self, position=None):
14921490

14931491
x_trf = self.xaxis.get_transform()
14941492
y_trf = self.yaxis.get_transform()
1495-
xmin, xmax = map(x_trf.transform, self.get_xbound())
1496-
ymin, ymax = map(y_trf.transform, self.get_ybound())
1493+
xmin, xmax = x_trf.transform(self.get_xbound())
1494+
ymin, ymax = y_trf.transform(self.get_ybound())
14971495
xsize = max(abs(xmax - xmin), 1e-30)
14981496
ysize = max(abs(ymax - ymin), 1e-30)
14991497

@@ -1507,8 +1505,8 @@ def apply_aspect(self, position=None):
15071505
return
15081506

15091507
dL = self.dataLim
1510-
x0, x1 = map(x_trf.transform, dL.intervalx)
1511-
y0, y1 = map(y_trf.transform, dL.intervaly)
1508+
x0, x1 = x_trf.transform(dL.intervalx)
1509+
y0, y1 = y_trf.transform(dL.intervaly)
15121510
xr = 1.05 * (x1 - x0)
15131511
yr = 1.05 * (y1 - y0)
15141512

@@ -1544,12 +1542,12 @@ def apply_aspect(self, position=None):
15441542
yc = 0.5 * (ymin + ymax)
15451543
y0 = yc - Ysize / 2.0
15461544
y1 = yc + Ysize / 2.0
1547-
self.set_ybound(*map(y_trf.inverted().transform, (y0, y1)))
1545+
self.set_ybound(y_trf.inverted().transform([y0, y1]))
15481546
else:
15491547
xc = 0.5 * (xmin + xmax)
15501548
x0 = xc - Xsize / 2.0
15511549
x1 = xc + Xsize / 2.0
1552-
self.set_xbound(*map(x_trf.inverted().transform, (x0, x1)))
1550+
self.set_xbound(x_trf.inverted().transform([x0, x1]))
15531551

15541552
def axis(self, *args, emit=True, **kwargs):
15551553
"""

0 commit comments

Comments
 (0)