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

Skip to content

Commit bbbb267

Browse files
committed
Try to improve the cursor readout and status message.
This could be done better with changes to the backends. The status (pan/zoom etc) should be indicated via the state of the buttons, e.g. using radio buttons, rather than by printing text. The readout should be positioned to minimize jumping around of the text. svn path=/trunk/matplotlib/; revision=7188
1 parent 885a22a commit bbbb267

3 files changed

Lines changed: 13 additions & 11 deletions

File tree

lib/matplotlib/axes.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2468,12 +2468,14 @@ def format_ydata(self, y):
24682468
def format_coord(self, x, y):
24692469
'return a format string formatting the *x*, *y* coord'
24702470
if x is None:
2471-
x = '???'
2471+
xs = '???'
2472+
else:
2473+
xs = self.format_xdata(x)
24722474
if y is None:
2473-
y = '???'
2474-
xs = self.format_xdata(x)
2475-
ys = self.format_ydata(y)
2476-
return 'x=%s, y=%s'%(xs,ys)
2475+
ys = '???'
2476+
else:
2477+
ys = self.format_ydata(y)
2478+
return 'x=%s y=%s'%(xs,ys)
24772479

24782480
#### Interactive manipulation
24792481

lib/matplotlib/backend_bases.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1460,7 +1460,7 @@ def print_figure(self, filename, dpi=None, facecolor='w', edgecolor='w',
14601460

14611461
restore_bbox = tight_bbox.adjust_bbox(self.figure, format,
14621462
bbox_inches)
1463-
1463+
14641464
_bbox_inches_restore = (bbox_inches, restore_bbox)
14651465
else:
14661466
_bbox_inches_restore = None
@@ -1896,7 +1896,7 @@ def mouse_move(self, event):
18961896
except OverflowError: pass
18971897
else:
18981898
if len(self.mode):
1899-
self.set_message('%s : %s' % (self.mode, s))
1899+
self.set_message('%s, %s' % (self.mode, s))
19001900
else:
19011901
self.set_message(s)
19021902
else: self.set_message(self.mode)
@@ -1923,7 +1923,7 @@ def pan(self,*args):
19231923
'button_press_event', self.press_pan)
19241924
self._idRelease = self.canvas.mpl_connect(
19251925
'button_release_event', self.release_pan)
1926-
self.mode = 'pan/zoom mode'
1926+
self.mode = 'pan/zoom'
19271927
self.canvas.widgetlock(self)
19281928
else:
19291929
self.canvas.widgetlock.release(self)
@@ -2193,7 +2193,7 @@ def zoom(self, *args):
21932193
if self._active:
21942194
self._idPress = self.canvas.mpl_connect('button_press_event', self.press_zoom)
21952195
self._idRelease = self.canvas.mpl_connect('button_release_event', self.release_zoom)
2196-
self.mode = 'Zoom to rect mode'
2196+
self.mode = 'zoom rect'
21972197
self.canvas.widgetlock(self)
21982198
else:
21992199
self.canvas.widgetlock.release(self)

lib/matplotlib/ticker.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ def set_powerlimits(self, lims):
344344

345345
def format_data_short(self,value):
346346
'return a short formatted string representation of a number'
347-
return '%1.3g'%value
347+
return '%-12g'%value
348348

349349
def format_data(self,value):
350350
'return a formatted string representation of a number'
@@ -525,7 +525,7 @@ def format_data(self,value):
525525

526526
def format_data_short(self,value):
527527
'return a short formatted string representation of a number'
528-
return '%1.3g'%value
528+
return '%-12g'%value
529529

530530
def is_decade(self, x):
531531
n = self.nearest_long(x)

0 commit comments

Comments
 (0)