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

Skip to content

Use get_x/yaxis_transform more. #18588

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions examples/subplots_axes_and_figures/axes_zoom_effect.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,22 @@ def connect_bbox(bbox1, bbox2,
prop_patches = {
**prop_lines,
"alpha": prop_lines.get("alpha", 1) * 0.2,
"clip_on": False,
}

c1 = BboxConnector(bbox1, bbox2, loc1=loc1a, loc2=loc2a, **prop_lines)
c1.set_clip_on(False)
c2 = BboxConnector(bbox1, bbox2, loc1=loc1b, loc2=loc2b, **prop_lines)
c2.set_clip_on(False)
c1 = BboxConnector(
bbox1, bbox2, loc1=loc1a, loc2=loc2a, clip_on=False, **prop_lines)
c2 = BboxConnector(
bbox1, bbox2, loc1=loc1b, loc2=loc2b, clip_on=False, **prop_lines)

bbox_patch1 = BboxPatch(bbox1, **prop_patches)
bbox_patch2 = BboxPatch(bbox2, **prop_patches)

p = BboxConnectorPatch(bbox1, bbox2,
# loc1a=3, loc2a=2, loc1b=4, loc2b=1,
loc1a=loc1a, loc2a=loc2a, loc1b=loc1b, loc2b=loc2b,
clip_on=False,
**prop_patches)
p.set_clip_on(False)

return c1, c2, bbox_patch1, bbox_patch2, p

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

trans1 = blended_transform_factory(ax1.transData, ax1.transAxes)
trans2 = blended_transform_factory(ax2.transData, ax2.transAxes)

bbox = Bbox.from_extents(xmin, 0, xmax, 1)

mybbox1 = TransformedBbox(bbox, trans1)
mybbox2 = TransformedBbox(bbox, trans2)
mybbox1 = TransformedBbox(bbox, ax1.get_xaxis_transform())
mybbox2 = TransformedBbox(bbox, ax2.get_xaxis_transform())

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

Expand Down
7 changes: 2 additions & 5 deletions lib/matplotlib/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from . import _api, cbook, colors, ticker
from .lines import Line2D
from .patches import Circle, Rectangle, Ellipse
from .transforms import blended_transform_factory


class LockDraw:
Expand Down Expand Up @@ -1716,12 +1715,10 @@ def new_axes(self, ax):
self.connect_default_events()

if self.direction == 'horizontal':
trans = blended_transform_factory(self.ax.transData,
self.ax.transAxes)
trans = ax.get_xaxis_transform()
w, h = 0, 1
else:
trans = blended_transform_factory(self.ax.transAxes,
self.ax.transData)
trans = ax.get_yaxis_transform()
w, h = 1, 0
self.rect = Rectangle((0, 0), w, h,
transform=trans,
Expand Down