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

Skip to content

Commit 0229820

Browse files
committed
invert logic and rename "set_capture_..." to "set_forward_..."
1 parent 1da690f commit 0229820

File tree

6 files changed

+38
-37
lines changed

6 files changed

+38
-37
lines changed

doc/api/axes_api.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,8 +515,8 @@ Interactive
515515
Axes.get_navigate_mode
516516
Axes.set_navigate_mode
517517

518-
Axes.get_capture_navigation_events
519-
Axes.set_capture_navigation_events
518+
Axes.get_forward_navigation_events
519+
Axes.set_forward_navigation_events
520520

521521
Axes.start_pan
522522
Axes.drag_pan

doc/api/next_api_changes/behavior/22347-RQ.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ background-patch (e.g. ``ax.patch.get_visible()``) and by the ``zorder`` of the
77
- Axes with a visible patch capture the event and do not pass it on to axes below.
88
Only the Axes with the highest ``zorder`` that contains the event is triggered
99
(if there are multiple Axes with the same ``zorder``, the last added Axes counts)
10-
- Axes with an invisible patch is also invisible to events and they are passed on to the axes below.
10+
- Axes with an invisible patch are also invisible to events and they are passed on to the axes below.
1111

1212
To override the default behavior and explicitly set whether an Axes
13-
should capture navigation events, use `.Axes.set_capture_navigation_events`.
13+
should forward navigation events, use `.Axes.set_forward_navigation_events`.

galleries/examples/showcase/pan_zoom_overlap.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@
1414
(irrespective of the patch visibility)
1515
1616
17-
``ax.set_capture_navigation_events(val)`` can be used to override the
17+
``ax.set_forward_navigation_events(val)`` can be used to override the
1818
default behaviour:
1919
20-
- ``False``: Forward navigation events to axes below
21-
- ``True``: Capture navigation events
20+
- ``True``: Forward navigation events to axes below.
21+
- ``False``: Execute navigation events only on this axes.
2222
- ``"auto"``: Use the default behaviour
23+
(``True`` for axes with an invisible patch and ``False`` otherwise).
2324
2425
To disable pan/zoom events completely, use ``ax.set_navigate(False)``
2526
"""
@@ -43,11 +44,11 @@
4344
ha="center", va="center", transform=ax1.transAxes)
4445

4546
ax11 = f.add_subplot(223, sharex=ax1, sharey=ax1)
46-
ax11.set_capture_navigation_events(False)
47+
ax11.set_forward_navigation_events(True)
4748
ax11.text(.5, .5,
4849
"Visible patch\n\n"
4950
"Override capture behavior:\n\n"
50-
"ax.set_capture_navigation_events(False)",
51+
"ax.set_forward_navigation_events(True)",
5152
ha="center", va="center", transform=ax11.transAxes)
5253

5354
ax2 = f.add_subplot(222)
@@ -61,9 +62,9 @@
6162

6263
ax22 = f.add_subplot(224, sharex=ax2, sharey=ax2)
6364
ax22.patch.set_visible(False)
64-
ax22.set_capture_navigation_events(True)
65+
ax22.set_forward_navigation_events(False)
6566
ax22.text(.5, .5,
6667
"Invisible patch\n\n"
6768
"Override capture behavior:\n\n"
68-
"ax.set_capture_navigation_events(True)",
69+
"ax.set_forward_navigation_events(False)",
6970
ha="center", va="center", transform=ax22.transAxes)

lib/matplotlib/axes/_base.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ def __init__(self, fig,
581581
xscale=None,
582582
yscale=None,
583583
box_aspect=None,
584-
capture_navigation_events="auto",
584+
forward_navigation_events="auto",
585585
**kwargs
586586
):
587587
"""
@@ -616,7 +616,7 @@ def __init__(self, fig,
616616
Set a fixed aspect for the Axes box, i.e. the ratio of height to
617617
width. See `~.axes.Axes.set_box_aspect` for details.
618618
619-
capture_navigation_events : bool or "auto", default: "auto"
619+
forward_navigation_events : bool or "auto", default: "auto"
620620
Control whether pan/zoom events are passed through to Axes below
621621
this one. "auto" is *True* for axes with an invisible patch and
622622
*False* otherwise.
@@ -656,7 +656,7 @@ def __init__(self, fig,
656656
self._adjustable = 'box'
657657
self._anchor = 'C'
658658
self._stale_viewlims = {name: False for name in self._axis_names}
659-
self._capture_navigation_events = capture_navigation_events
659+
self._forward_navigation_events = forward_navigation_events
660660
self._sharex = sharex
661661
self._sharey = sharey
662662
self.set_label(label)
@@ -3970,7 +3970,7 @@ def set_navigate(self, b):
39703970
39713971
See Also
39723972
--------
3973-
matplotlib.axes.Axes.set_capture_navigation_events
3973+
matplotlib.axes.Axes.set_forward_navigation_events
39743974
39753975
"""
39763976
self._navigate = b
@@ -4549,30 +4549,30 @@ def _label_outer_yaxis(self, *, check_patch):
45494549
if self.yaxis.offsetText.get_position()[0] == 1:
45504550
self.yaxis.offsetText.set_visible(False)
45514551

4552-
def set_capture_navigation_events(self, capture):
4552+
def set_forward_navigation_events(self, forward):
45534553
"""
45544554
Set how pan/zoom events are forwarded to Axes below this one.
45554555
45564556
Parameters
45574557
----------
4558-
capture : bool or 'auto'
4558+
forward : bool or "auto"
45594559
Possible values:
45604560
4561-
- True: Events are only executed on this axes.
4562-
- False: Forward events to other axes with lower or equal zorder
4563-
- "auto": Default behaviour ("True" for axes with an invisible
4564-
patch and False otherwise)
4561+
- True: Forward events to other axes with lower or equal zorder.
4562+
- False: Events are only executed on this axes.
4563+
- "auto": Default behaviour (*True* for axes with an invisible
4564+
patch and *False* otherwise)
45654565
45664566
See Also
45674567
--------
45684568
matplotlib.axes.Axes.set_navigate
45694569
45704570
"""
4571-
self._capture_navigation_events = capture
4571+
self._forward_navigation_events = forward
45724572

4573-
def get_capture_navigation_events(self):
4573+
def get_forward_navigation_events(self):
45744574
"""Get how pan/zoom events are forwarded to Axes below this one."""
4575-
return self._capture_navigation_events
4575+
return self._forward_navigation_events
45764576

45774577

45784578
def _draw_rasterized(figure, artists, renderer):

lib/matplotlib/backend_bases.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2983,11 +2983,11 @@ def _start_event_axes_pan(self, event):
29832983
def _ax_filter(ax):
29842984
return ax.in_axes(event) and ax.get_navigate() and ax.can_zoom()
29852985

2986-
def _ax_capture(ax):
2987-
c = ax.get_capture_navigation_events()
2988-
if c == "auto": # (capture = patch visibility)
2989-
c = ax.patch.get_visible()
2990-
return c
2986+
def _capture_events(ax):
2987+
f = ax.get_forward_navigation_events()
2988+
if f == "auto": # (capture = patch visibility)
2989+
f = not ax.patch.get_visible()
2990+
return not f
29912991

29922992
# get all relevant axes for the event
29932993
axes = list(filter(_ax_filter, self.canvas.figure.get_axes()))
@@ -3022,7 +3022,7 @@ def _ax_capture(ax):
30223022
# only trigger twinned-axes not the shared axes!
30233023
pan_axes.extend((i for i in ax_t if i is not ax_s))
30243024

3025-
if _ax_capture(ax):
3025+
if _capture_events(ax):
30263026
break # break if we hit a capturing axes
30273027
else:
30283028
continue # continue to lower zorder if we did not break

lib/matplotlib/tests/test_backend_bases.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -444,14 +444,14 @@ def test_toolmanager_update_keymap():
444444
@pytest.mark.parametrize("tool", ["zoom", "pan"])
445445
@pytest.mark.parametrize("button", [MouseButton.LEFT, MouseButton.RIGHT])
446446
@pytest.mark.parametrize("patch_vis", [True, False])
447-
@pytest.mark.parametrize("capture_nav", [True, False, "auto"])
447+
@pytest.mark.parametrize("forward_nav", [True, False, "auto"])
448448
@pytest.mark.parametrize("t_s", ["twin", "share"])
449449
def test_interactive_pan_zoom_events(tool, button, patch_vis,
450-
capture_nav, t_s):
450+
forward_nav, t_s):
451451
# Bottom axes: ax_b Top axes: ax_t
452452
fig, ax_b = plt.subplots()
453453
ax_t = fig.add_subplot(221, zorder=99)
454-
ax_t.set_capture_navigation_events(capture_nav)
454+
ax_t.set_forward_navigation_events(forward_nav)
455455
ax_t.patch.set_visible(patch_vis)
456456

457457
# ----------------------------
@@ -515,10 +515,10 @@ def test_interactive_pan_zoom_events(tool, button, patch_vis,
515515
xlim_t, ylim_t = ax_t._prepare_view_from_bbox(
516516
[*s0, *s1], direction)
517517

518-
if ax_t.get_capture_navigation_events() is False:
518+
if ax_t.get_forward_navigation_events() is True:
519519
xlim_b, ylim_b = ax_b._prepare_view_from_bbox(
520520
[*s0, *s1], direction)
521-
elif ax_t.get_capture_navigation_events() is True:
521+
elif ax_t.get_forward_navigation_events() is False:
522522
xlim_b = init_xlim
523523
ylim_b = init_ylim
524524
else:
@@ -552,12 +552,12 @@ def test_interactive_pan_zoom_events(tool, button, patch_vis,
552552
button, None, *s1).T.astype(float)
553553
ax_t.end_pan()
554554

555-
if ax_t.get_capture_navigation_events() is False:
555+
if ax_t.get_forward_navigation_events() is True:
556556
ax_b.start_pan(*s0, button)
557557
xlim_b, ylim_b = ax_b._get_pan_points(
558558
button, None, *s1).T.astype(float)
559559
ax_b.end_pan()
560-
elif ax_t.get_capture_navigation_events() is True:
560+
elif ax_t.get_forward_navigation_events() is False:
561561
xlim_b = init_xlim
562562
ylim_b = init_ylim
563563
else:

0 commit comments

Comments
 (0)