File tree Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -422,14 +422,25 @@ def __call__(self):
422422 return [tick for tick in self .base () if tick > rorigin ]
423423 return self .base ()
424424
425+ def _zero_in_bounds (self ):
426+ """
427+ Return True if zero is within the valid values for the
428+ scale of the radial axis.
429+ """
430+ vmin , vmax = self ._axes .yaxis ._scale .limit_range_for_scale (0 , 1 , 1e-5 )
431+ return vmin == 0
432+
425433 def nonsingular (self , vmin , vmax ):
426434 # docstring inherited
427- return ((0 , 1 ) if (vmin , vmax ) == (- np .inf , np .inf ) # Init. limits.
428- else self .base .nonsingular (vmin , vmax ))
435+ if self ._zero_in_bounds () and (vmin , vmax ) == (- np .inf , np .inf ):
436+ # Initial view limits
437+ return (0 , 1 )
438+ else :
439+ return self .base .nonsingular (vmin , vmax )
429440
430441 def view_limits (self , vmin , vmax ):
431442 vmin , vmax = self .base .view_limits (vmin , vmax )
432- if vmax > vmin :
443+ if self . _zero_in_bounds () and vmax > vmin :
433444 # this allows inverted r/y-lims
434445 vmin = min (0 , vmin )
435446 return mtransforms .nonsingular (vmin , vmax )
Original file line number Diff line number Diff line change @@ -291,6 +291,13 @@ def test_polar_no_data():
291291 assert ax .get_rmin () == 0 and ax .get_rmax () == 1
292292
293293
294+ def test_polar_default_log_lims ():
295+ plt .subplot (projection = 'polar' )
296+ ax = plt .gca ()
297+ ax .set_rscale ('log' )
298+ assert ax .get_rmin () > 0
299+
300+
294301def test_polar_not_datalim_adjustable ():
295302 ax = plt .figure ().add_subplot (projection = "polar" )
296303 with pytest .raises (ValueError ):
You can’t perform that action at this time.
0 commit comments