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

Skip to content

Commit c5c1a0c

Browse 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

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

lib/matplotlib/artist.py

Lines 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

Lines 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

Lines 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)