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 c5c1a0c

Browse filesBrowse files
author
castany
committed
Change hardcoded brackets for Toolbar message
Remove the brackets that were harcoded in methods NavigationToolbar2.mouse_move() and ToolCursorPosition.send_message(). Move them rather to the method Artist.format_cursor_data(), because that method that can easily be overwritten.
1 parent 24f0d9c commit c5c1a0c
Copy full SHA for c5c1a0c

File tree

Expand file treeCollapse file tree

3 files changed

+9
-4
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+9
-4
lines changed

‎lib/matplotlib/artist.py

Copy file name to clipboardExpand all lines: lib/matplotlib/artist.py
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,8 +1059,9 @@ def format_cursor_data(self, data):
10591059
data[0]
10601060
except (TypeError, IndexError):
10611061
data = [data]
1062-
return ', '.join('{:0.3g}'.format(item) for item in data if
1063-
isinstance(item, (np.floating, np.integer, int, float)))
1062+
data_str = ', '.join('{:0.3g}'.format(item) for item in data if
1063+
isinstance(item, (np.floating, np.integer, int, float)))
1064+
return "[" + data_str + "]"
10641065

10651066
@property
10661067
def mouseover(self):

‎lib/matplotlib/backend_bases.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backend_bases.py
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2898,7 +2898,9 @@ def mouse_move(self, event):
28982898
if a is not event.inaxes.patch:
28992899
data = a.get_cursor_data(event)
29002900
if data is not None:
2901-
s += ' [%s]' % a.format_cursor_data(data)
2901+
data_str = a.format_cursor_data(data)
2902+
if data_str is not None:
2903+
s = s + ' ' + data_str
29022904

29032905
if len(self.mode):
29042906
self.set_message('%s, %s' % (self.mode, s))

‎lib/matplotlib/backend_tools.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backend_tools.py
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,9 @@ def send_message(self, event):
344344
if a is not event.inaxes.patch:
345345
data = a.get_cursor_data(event)
346346
if data is not None:
347-
s += ' [%s]' % a.format_cursor_data(data)
347+
data_str = a.format_cursor_data(data)
348+
if data_str is not None:
349+
s = s + ' ' + data_str
348350

349351
message = s
350352
self.toolmanager.message_event(message, self)

0 commit comments

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