File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed
Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -455,7 +455,7 @@ def set_locs(self, locs):
455455 if self ._useOffset :
456456 self ._set_offset (d )
457457 self ._set_orderOfMagnitude (d )
458- self ._set_format ()
458+ self ._set_format (vmin , vmax )
459459
460460 def _set_offset (self , range ):
461461 # offset of 20,001 is 20,000, for example
@@ -496,10 +496,19 @@ def _set_orderOfMagnitude(self,range):
496496 else :
497497 self .orderOfMagnitude = 0
498498
499- def _set_format (self ):
499+ def _set_format (self , vmin , vmax ):
500500 # set the format string to format all the ticklabels
501- locs = (np .asarray (self .locs )- self .offset ) / 10 ** self .orderOfMagnitude
502- loc_range_oom = int (math .floor (math .log10 (np .ptp (locs ))))
501+ if len (self .locs ) < 2 :
502+ # Temporarily augment the locations with the axis end points.
503+ _locs = list (self .locs ) + [vmin , vmax ]
504+ else :
505+ _locs = self .locs
506+ locs = (np .asarray (_locs )- self .offset ) / 10 ** self .orderOfMagnitude
507+ loc_range = np .ptp (locs )
508+ if len (self .locs ) < 2 :
509+ # We needed the end points only for the loc_range calculation.
510+ locs = locs [:- 2 ]
511+ loc_range_oom = int (math .floor (math .log10 (loc_range )))
503512 # first estimate:
504513 sigfigs = max (0 , 3 - loc_range_oom )
505514 # refined estimate:
You can’t perform that action at this time.
0 commit comments