@@ -506,3 +506,23 @@ def test_polar_errorbar(order):
506506 ax .errorbar (theta , r , xerr = 0.1 , yerr = 0.1 , capsize = 7 , fmt = "o" , c = "seagreen" )
507507 ax .set_theta_zero_location ("N" )
508508 ax .set_theta_direction (- 1 )
509+
510+
511+ def test_radial_limits_behavior ():
512+ # r=0 is kept as limit if positive data and ticks are used
513+ # negative ticks or data result in negative limits
514+ fig = plt .figure ()
515+ ax = fig .add_subplot (projection = 'polar' )
516+ assert ax .get_ylim () == (0 , 1 )
517+ # upper limit is expanded to include the ticks, but lower limit stays at 0
518+ ax .set_rticks ([1 , 2 , 3 , 4 ])
519+ assert ax .get_ylim () == (0 , 4 )
520+ # upper limit is autoscaled to data, but lower limit limit stays 0
521+ ax .plot ([1 , 2 ], [1 , 2 ])
522+ assert ax .get_ylim () == (0 , 2 )
523+ # negative ticks also expand the negative limit
524+ ax .set_rticks ([- 1 , 0 , 1 , 2 ])
525+ assert ax .get_ylim () == (- 1 , 2 )
526+ # negative data also autoscales to negative limits
527+ ax .plot ([1 , 2 ], [- 1 , - 2 ])
528+ assert ax .get_ylim () == (- 2 , 2 )
0 commit comments