@@ -628,44 +628,58 @@ def test_const_xy():
628
628
plt .plot (np .ones (10 ), np .ones (10 ), 'o' )
629
629
630
630
631
- @image_comparison (['polar_wrap_180' , 'polar_wrap_360' ], style = 'default' )
632
- def test_polar_wrap ():
631
+ def test_polar_twice ():
633
632
fig = plt .figure ()
634
- plt .subplot (111 , polar = True )
635
- plt .polar (np .deg2rad ([179 , - 179 ]), [0.2 , 0.1 ], "b.-" )
636
- plt .polar (np .deg2rad ([179 , 181 ]), [0.2 , 0.1 ], "g.-" )
637
- plt .rgrids ([0.05 , 0.1 , 0.15 , 0.2 , 0.25 , 0.3 ])
633
+ plt .polar ([1 , 2 ], [.1 , .2 ])
634
+ plt .polar ([3 , 4 ], [.3 , .4 ])
638
635
assert len (fig .axes ) == 1 , 'More than one polar axes created.'
639
636
640
- fig = plt .figure ()
641
- plt .subplot (111 , polar = True )
642
- plt .polar (np .deg2rad ([2 , - 2 ]), [0.2 , 0.1 ], "b.-" )
643
- plt .polar (np .deg2rad ([2 , 358 ]), [0.2 , 0.1 ], "g.-" )
644
- plt .polar (np .deg2rad ([358 , 2 ]), [0.2 , 0.1 ], "r.-" )
645
- plt .rgrids ([0.05 , 0.1 , 0.15 , 0.2 , 0.25 , 0.3 ])
637
+
638
+ @check_figures_equal ()
639
+ def test_polar_wrap (fig_test , fig_ref ):
640
+ ax = fig_test .add_subplot (projection = "polar" )
641
+ ax .plot (np .deg2rad ([179 , - 179 ]), [0.2 , 0.1 ])
642
+ ax .plot (np .deg2rad ([2 , - 2 ]), [0.2 , 0.1 ])
643
+ ax = fig_ref .add_subplot (projection = "polar" )
644
+ ax .plot (np .deg2rad ([179 , 181 ]), [0.2 , 0.1 ])
645
+ ax .plot (np .deg2rad ([2 , 358 ]), [0.2 , 0.1 ])
646
646
647
647
648
- @image_comparison ([ 'polar_units' , 'polar_units_2' ], style = 'default' )
649
- def test_polar_units ( ):
648
+ @check_figures_equal ( )
649
+ def test_polar_units_1 ( fig_test , fig_ref ):
650
650
import matplotlib .testing .jpl_units as units
651
651
units .register ()
652
+ xs = [30.0 , 45.0 , 60.0 , 90.0 ]
653
+ ys = [1.0 , 2.0 , 3.0 , 4.0 ]
652
654
653
- deg = units . deg
654
- km = units .km
655
+ plt . figure ( fig_test . number )
656
+ plt . polar ([ x * units .deg for x in xs ], ys )
655
657
656
- xs = [30.0 * deg , 45.0 * deg , 60.0 * deg , 90.0 * deg ]
657
- ys = [1.0 , 2.0 , 3.0 , 4.0 ]
658
+ ax = fig_ref .add_subplot (projection = "polar" )
659
+ ax .plot (np .deg2rad (xs ), ys )
660
+ ax .set (xlabel = "deg" )
658
661
659
- plt .figure ()
660
- plt .polar (xs , ys , color = "blue" )
661
662
662
- plt .figure ()
663
- # make sure runits and theta units work
664
- ykm = [y * km for y in ys ]
665
- plt .polar (xs , ykm , color = "blue" , thetaunits = "rad" , runits = "km" )
663
+ @check_figures_equal ()
664
+ def test_polar_units_2 (fig_test , fig_ref ):
665
+ import matplotlib .testing .jpl_units as units
666
+ units .register ()
667
+ xs = [30.0 , 45.0 , 60.0 , 90.0 ]
668
+ xs_deg = [x * units .deg for x in xs ]
669
+ ys = [1.0 , 2.0 , 3.0 , 4.0 ]
670
+ ys_km = [y * units .km for y in ys ]
671
+
672
+ plt .figure (fig_test .number )
673
+ # test {theta,r}units.
674
+ plt .polar (xs_deg , ys_km , thetaunits = "rad" , runits = "km" )
666
675
assert isinstance (plt .gca ().get_xaxis ().get_major_formatter (),
667
676
units .UnitDblFormatter )
668
677
678
+ ax = fig_ref .add_subplot (projection = "polar" )
679
+ ax .plot (np .deg2rad (xs ), ys )
680
+ ax .xaxis .set_major_formatter (mticker .FuncFormatter ("{:.12}" .format ))
681
+ ax .set (xlabel = "rad" , ylabel = "km" )
682
+
669
683
670
684
@image_comparison (['polar_rmin' ], style = 'default' )
671
685
def test_polar_rmin ():
0 commit comments