File tree 1 file changed +23
-13
lines changed
1 file changed +23
-13
lines changed Original file line number Diff line number Diff line change @@ -1527,15 +1527,22 @@ def __call__(self):
1527
1527
try :
1528
1528
majorstep = majorlocs [1 ] - majorlocs [0 ]
1529
1529
except IndexError :
1530
- raise ValueError ('Need at least two major ticks to find minor '
1531
- 'tick locations' )
1530
+ # Need at least two major ticks to find minor tick locations
1531
+ # TODO: Figure out a way to still be able to display minor
1532
+ # ticks without two major ticks visible. For now, just display
1533
+ # no ticks at all.
1534
+ majorstep = 0
1532
1535
1533
1536
if self .ndivs is None :
1534
- x = int (round (10 ** (np .log10 (majorstep ) % 1 )))
1535
- if x in [1 , 5 , 10 ]:
1536
- ndivs = 5
1537
- else :
1538
- ndivs = 4
1537
+ if majorstep == 0 :
1538
+ # TODO: Need a better way to figure out ndivs
1539
+ ndivs = 1
1540
+ else :
1541
+ x = int (round (10 ** (np .log10 (majorstep ) % 1 )))
1542
+ if x in [1 , 5 , 10 ]:
1543
+ ndivs = 5
1544
+ else :
1545
+ ndivs = 4
1539
1546
else :
1540
1547
ndivs = self .ndivs
1541
1548
@@ -1545,12 +1552,15 @@ def __call__(self):
1545
1552
if vmin > vmax :
1546
1553
vmin ,vmax = vmax ,vmin
1547
1554
1548
- t0 = majorlocs [0 ]
1549
- tmin = np .ceil ((vmin - t0 ) / minorstep ) * minorstep
1550
- tmax = np .floor ((vmax - t0 ) / minorstep ) * minorstep
1551
- locs = np .arange (tmin , tmax , minorstep ) + t0
1552
- cond = np .abs ((locs - t0 ) % majorstep ) > minorstep / 10.0
1553
- locs = locs .compress (cond )
1555
+ if len (majorlocs ) > 0 :
1556
+ t0 = majorlocs [0 ]
1557
+ tmin = np .ceil ((vmin - t0 ) / minorstep ) * minorstep
1558
+ tmax = np .floor ((vmax - t0 ) / minorstep ) * minorstep
1559
+ locs = np .arange (tmin , tmax , minorstep ) + t0
1560
+ cond = np .abs ((locs - t0 ) % majorstep ) > minorstep / 10.0
1561
+ locs = locs .compress (cond )
1562
+ else :
1563
+ locs = []
1554
1564
1555
1565
return self .raise_if_exceeds (np .array (locs ))
1556
1566
You can’t perform that action at this time.
0 commit comments