Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 51e77e1

Browse filesBrowse files
authored
Merge pull request #12141 from anntzer/axesnav
Let digits toggle axes nav only if they correspond to an existing axes.
2 parents 2fd8f26 + 4915168 commit 51e77e1
Copy full SHA for 51e77e1

File tree

Expand file treeCollapse file tree

2 files changed

+18
-18
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+18
-18
lines changed
Open diff view settings
Collapse file

‎lib/matplotlib/backend_bases.py‎

Copy file name to clipboardExpand all lines: lib/matplotlib/backend_bases.py
+13-14Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2375,21 +2375,20 @@ def _get_uniform_gridstate(ticks):
23752375
_log.warning(str(exc))
23762376
ax.set_xscale('linear')
23772377
ax.figure.canvas.draw_idle()
2378-
2379-
elif (event.key.isdigit() and event.key != '0') or event.key in all_keys:
2380-
# keys in list 'all' enables all axes (default key 'a'),
2381-
# otherwise if key is a number only enable this particular axes
2382-
# if it was the axes, where the event was raised
2383-
if event.key not in all_keys:
2384-
n = int(event.key) - 1
2385-
for i, a in enumerate(canvas.figure.get_axes()):
2386-
# consider axes, in which the event was raised
2387-
# FIXME: Why only this axes?
2378+
# enable nagivation for all axes that contain the event (default key 'a')
2379+
elif event.key in all_keys:
2380+
for a in canvas.figure.get_axes():
23882381
if (event.x is not None and event.y is not None
2389-
and a.in_axes(event)):
2390-
if event.key in all_keys:
2391-
a.set_navigate(True)
2392-
else:
2382+
and a.in_axes(event)): # FIXME: Why only these?
2383+
a.set_navigate(True)
2384+
# enable navigation only for axes with this index (if such an axes exist,
2385+
# otherwise do nothing)
2386+
elif event.key.isdigit() and event.key != '0':
2387+
n = int(event.key) - 1
2388+
if n < len(canvas.figure.get_axes()):
2389+
for i, a in enumerate(canvas.figure.get_axes()):
2390+
if (event.x is not None and event.y is not None
2391+
and a.in_axes(event)): # FIXME: Why only these?
23932392
a.set_navigate(i == n)
23942393

23952394

Collapse file

‎lib/matplotlib/backend_tools.py‎

Copy file name to clipboardExpand all lines: lib/matplotlib/backend_tools.py
+5-4Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -427,10 +427,11 @@ def trigger(self, sender, event, data=None):
427427
return
428428

429429
n = int(event.key) - 1
430-
for i, a in enumerate(self.figure.get_axes()):
431-
if (event.x is not None and event.y is not None
432-
and a.in_axes(event)):
433-
a.set_navigate(i == n)
430+
if n < len(self.figure.get_axes()):
431+
for i, a in enumerate(self.figure.get_axes()):
432+
if (event.x is not None and event.y is not None
433+
and a.in_axes(event)):
434+
a.set_navigate(i == n)
434435

435436

436437
class _ToolGridBase(ToolBase):

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.