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