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):
455
455
if self ._useOffset :
456
456
self ._set_offset (d )
457
457
self ._set_orderOfMagnitude (d )
458
- self ._set_format ()
458
+ self ._set_format (vmin , vmax )
459
459
460
460
def _set_offset (self , range ):
461
461
# offset of 20,001 is 20,000, for example
@@ -496,10 +496,19 @@ def _set_orderOfMagnitude(self,range):
496
496
else :
497
497
self .orderOfMagnitude = 0
498
498
499
- def _set_format (self ):
499
+ def _set_format (self , vmin , vmax ):
500
500
# 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 )))
503
512
# first estimate:
504
513
sigfigs = max (0 , 3 - loc_range_oom )
505
514
# refined estimate:
You can’t perform that action at this time.
0 commit comments