@@ -2791,32 +2791,38 @@ def ideal_ticks(x):
2791
2791
return MaxNLocator .tick_values (self , vmin , vmax )
2792
2792
2793
2793
def nonsingular (self , vmin , vmax ):
2794
- initial_range = (1e-7 , 1 - 1e-7 )
2795
- if not np .isfinite (vmin ) or not np .isfinite (vmax ):
2796
- return initial_range # no data plotted yet
2797
-
2794
+ standard_minpos = 1e-7
2795
+ initial_range = (standard_minpos , 1 - standard_minpos )
2798
2796
if vmin > vmax :
2799
2797
vmin , vmax = vmax , vmin
2800
-
2801
- # what to do if a window beyond ]0, 1[ is chosen
2802
- if self .axis is not None :
2803
- minpos = self .axis .get_minpos ()
2804
- if not np .isfinite (minpos ):
2805
- return initial_range # again, no data plotted
2798
+ if not np .isfinite (vmin ) or not np .isfinite (vmax ):
2799
+ vmin , vmax = initial_range # Initial range, no data plotted yet.
2800
+ elif vmax <= 0 or vmin >= 1 :
2801
+ # vmax <= 0 occurs when all values are negative
2802
+ # vmin >= 1 occurs when all values are greater than one
2803
+ cbook ._warn_external (
2804
+ "Data has no values between 0 and 1, and therefore cannot be "
2805
+ "logit-scaled."
2806
+ )
2807
+ vmin , vmax = initial_range
2806
2808
else :
2807
- minpos = 1e-7 # should not occur in normal use
2808
-
2809
- # NOTE: for vmax, we should query a property similar to get_minpos, but
2810
- # related to the maximal, less-than-one data point. Unfortunately,
2811
- # Bbox._minpos is defined very deep in the BBox and updated with data,
2812
- # so for now we use 1 - minpos as a substitute.
2813
-
2814
- if vmin <= 0 :
2815
- vmin = minpos
2816
- if vmax >= 1 :
2817
- vmax = 1 - minpos
2818
- if vmin == vmax :
2819
- return 0.1 * vmin , 1 - 0.1 * vmin
2809
+ minpos = (
2810
+ self .axis .get_minpos ()
2811
+ if self .axis is not None
2812
+ else standard_minpos
2813
+ )
2814
+ if not np .isfinite (minpos ):
2815
+ minpos = standard_minpos # This should never take effect.
2816
+ if vmin <= 0 :
2817
+ vmin = minpos
2818
+ # NOTE: for vmax, we should query a property similar to get_minpos,
2819
+ # but related to the maximal, less-than-one data point.
2820
+ # Unfortunately, Bbox._minpos is defined very deep in the BBox and
2821
+ # updated with data, so for now we use 1 - minpos as a substitute.
2822
+ if vmax >= 1 :
2823
+ vmax = 1 - minpos
2824
+ if vmin == vmax :
2825
+ vmin , vmax = 0.1 * vmin , 1 - 0.1 * vmin
2820
2826
2821
2827
return vmin , vmax
2822
2828
0 commit comments