File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -909,6 +909,21 @@ def get_zdata(self, event):
909909 """
910910 return ''
911911
912+ def format_zdata (self , z ):
913+ """
914+ Return *z* string formatted.
915+ """
916+ try :
917+ is_int = isinstance (z [0 ], int )
918+ except (TypeError , IndexError ):
919+ is_int = isinstance (z , int )
920+ z = [z ]
921+ if is_int :
922+ z = ', ' .join ('{:0}' .format (item ) for item in z )
923+ else :
924+ z = ', ' .join ('{:0.3g}' .format (item ) for item in z )
925+ return z
926+
912927
913928class ArtistInspector (object ):
914929 """
Original file line number Diff line number Diff line change @@ -696,11 +696,7 @@ def get_zdata(self, event):
696696 y , x = event .ydata , event .xdata
697697 i , j = trans .transform_point ([y , x ]).astype (int )
698698 z = arr [i , j ]
699- if z .size > 1 :
700- # Override default numpy formatting for this specific case.
701- # Bad idea?
702- z = ', ' .join ('{:0.3g}' .format (item ) for item in z )
703- return 'z=%s' % z
699+ return 'z=%s' % self .format_zdata (z )
704700
705701
706702class NonUniformImage (AxesImage ):
You can’t perform that action at this time.
0 commit comments