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

Skip to content

Commit e3b6798

Browse files
authored
Merge pull request #18588 from anntzer/xyaxis_transform
Use get_x/yaxis_transform more.
2 parents fd2a95f + c723492 commit e3b6798

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

examples/subplots_axes_and_figures/axes_zoom_effect.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,22 @@ def connect_bbox(bbox1, bbox2,
1818
prop_patches = {
1919
**prop_lines,
2020
"alpha": prop_lines.get("alpha", 1) * 0.2,
21+
"clip_on": False,
2122
}
2223

23-
c1 = BboxConnector(bbox1, bbox2, loc1=loc1a, loc2=loc2a, **prop_lines)
24-
c1.set_clip_on(False)
25-
c2 = BboxConnector(bbox1, bbox2, loc1=loc1b, loc2=loc2b, **prop_lines)
26-
c2.set_clip_on(False)
24+
c1 = BboxConnector(
25+
bbox1, bbox2, loc1=loc1a, loc2=loc2a, clip_on=False, **prop_lines)
26+
c2 = BboxConnector(
27+
bbox1, bbox2, loc1=loc1b, loc2=loc2b, clip_on=False, **prop_lines)
2728

2829
bbox_patch1 = BboxPatch(bbox1, **prop_patches)
2930
bbox_patch2 = BboxPatch(bbox2, **prop_patches)
3031

3132
p = BboxConnectorPatch(bbox1, bbox2,
3233
# loc1a=3, loc2a=2, loc1b=4, loc2b=1,
3334
loc1a=loc1a, loc2a=loc2a, loc1b=loc1b, loc2b=loc2b,
35+
clip_on=False,
3436
**prop_patches)
35-
p.set_clip_on(False)
3637

3738
return c1, c2, bbox_patch1, bbox_patch2, p
3839

@@ -54,13 +55,10 @@ def zoom_effect01(ax1, ax2, xmin, xmax, **kwargs):
5455
Arguments passed to the patch constructor.
5556
"""
5657

57-
trans1 = blended_transform_factory(ax1.transData, ax1.transAxes)
58-
trans2 = blended_transform_factory(ax2.transData, ax2.transAxes)
59-
6058
bbox = Bbox.from_extents(xmin, 0, xmax, 1)
6159

62-
mybbox1 = TransformedBbox(bbox, trans1)
63-
mybbox2 = TransformedBbox(bbox, trans2)
60+
mybbox1 = TransformedBbox(bbox, ax1.get_xaxis_transform())
61+
mybbox2 = TransformedBbox(bbox, ax2.get_xaxis_transform())
6462

6563
prop_patches = {**kwargs, "ec": "none", "alpha": 0.2}
6664

lib/matplotlib/widgets.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
from . import _api, cbook, colors, ticker
2020
from .lines import Line2D
2121
from .patches import Circle, Rectangle, Ellipse
22-
from .transforms import blended_transform_factory
2322

2423

2524
class LockDraw:
@@ -1716,12 +1715,10 @@ def new_axes(self, ax):
17161715
self.connect_default_events()
17171716

17181717
if self.direction == 'horizontal':
1719-
trans = blended_transform_factory(self.ax.transData,
1720-
self.ax.transAxes)
1718+
trans = ax.get_xaxis_transform()
17211719
w, h = 0, 1
17221720
else:
1723-
trans = blended_transform_factory(self.ax.transAxes,
1724-
self.ax.transData)
1721+
trans = ax.get_yaxis_transform()
17251722
w, h = 1, 0
17261723
self.rect = Rectangle((0, 0), w, h,
17271724
transform=trans,

0 commit comments

Comments
 (0)