@@ -492,95 +492,6 @@ def test_annotate_default_arrow():
492
492
assert ann .arrow_patch is not None
493
493
494
494
495
- @image_comparison (['polar_axes' ], style = 'default' )
496
- def test_polar_annotations ():
497
- # you can specify the xypoint and the xytext in different
498
- # positions and coordinate systems, and optionally turn on a
499
- # connecting line and mark the point with a marker. Annotations
500
- # work on polar axes too. In the example below, the xy point is
501
- # in native coordinates (xycoords defaults to 'data'). For a
502
- # polar axes, this is in (theta, radius) space. The text in this
503
- # example is placed in the fractional figure coordinate system.
504
- # Text keyword args like horizontal and vertical alignment are
505
- # respected
506
-
507
- # Setup some data
508
- r = np .arange (0.0 , 1.0 , 0.001 )
509
- theta = 2.0 * 2.0 * np .pi * r
510
-
511
- fig = plt .figure ()
512
- ax = fig .add_subplot (111 , polar = True )
513
- line , = ax .plot (theta , r , color = '#ee8d18' , lw = 3 )
514
- line , = ax .plot ((0 , 0 ), (0 , 1 ), color = "#0000ff" , lw = 1 )
515
-
516
- ind = 800
517
- thisr , thistheta = r [ind ], theta [ind ]
518
- ax .plot ([thistheta ], [thisr ], 'o' )
519
- ax .annotate ('a polar annotation' ,
520
- xy = (thistheta , thisr ), # theta, radius
521
- xytext = (0.05 , 0.05 ), # fraction, fraction
522
- textcoords = 'figure fraction' ,
523
- arrowprops = dict (facecolor = 'black' , shrink = 0.05 ),
524
- horizontalalignment = 'left' ,
525
- verticalalignment = 'baseline' ,
526
- )
527
-
528
- ax .tick_params (axis = 'x' , tick1On = True , tick2On = True , direction = 'out' )
529
-
530
-
531
- @image_comparison (['polar_coords' ], style = 'default' , remove_text = True )
532
- def test_polar_coord_annotations ():
533
- # You can also use polar notation on a cartesian axes. Here the
534
- # native coordinate system ('data') is cartesian, so you need to
535
- # specify the xycoords and textcoords as 'polar' if you want to
536
- # use (theta, radius)
537
- el = mpatches .Ellipse ((0 , 0 ), 10 , 20 , facecolor = 'r' , alpha = 0.5 )
538
-
539
- fig = plt .figure ()
540
- ax = fig .add_subplot (111 , aspect = 'equal' )
541
-
542
- ax .add_artist (el )
543
- el .set_clip_box (ax .bbox )
544
-
545
- ax .annotate ('the top' ,
546
- xy = (np .pi / 2. , 10. ), # theta, radius
547
- xytext = (np .pi / 3 , 20. ), # theta, radius
548
- xycoords = 'polar' ,
549
- textcoords = 'polar' ,
550
- arrowprops = dict (facecolor = 'black' , shrink = 0.05 ),
551
- horizontalalignment = 'left' ,
552
- verticalalignment = 'baseline' ,
553
- clip_on = True , # clip to the axes bounding box
554
- )
555
-
556
- ax .set_xlim (- 20 , 20 )
557
- ax .set_ylim (- 20 , 20 )
558
-
559
-
560
- @image_comparison (['polar_alignment.png' ])
561
- def test_polar_alignment ():
562
- """
563
- Test that changing the vertical/horizontal alignment of a polar graph
564
- works as expected.
565
- """
566
- angles = np .arange (0 , 360 , 90 )
567
- grid_values = [0 , 0.2 , 0.4 , 0.6 , 0.8 , 1 ]
568
-
569
- fig = plt .figure ()
570
- rect = [0.1 , 0.1 , 0.8 , 0.8 ]
571
-
572
- horizontal = fig .add_axes (rect , polar = True , label = 'horizontal' )
573
- horizontal .set_thetagrids (angles )
574
-
575
- vertical = fig .add_axes (rect , polar = True , label = 'vertical' )
576
- vertical .patch .set_visible (False )
577
-
578
- for i in range (2 ):
579
- fig .axes [i ].set_rgrids (
580
- grid_values , angle = angles [i ],
581
- horizontalalignment = 'left' , verticalalignment = 'top' )
582
-
583
-
584
495
@image_comparison (['fill_units.png' ], savefig_kwarg = {'dpi' : 60 })
585
496
def test_fill_units ():
586
497
import matplotlib .testing .jpl_units as units
@@ -686,189 +597,6 @@ def test_structured_data():
686
597
axs [1 ].plot ("ones" , "twos" , "r" , data = pts )
687
598
688
599
689
- def test_polar_twice ():
690
- fig = plt .figure ()
691
- plt .polar ([1 , 2 ], [.1 , .2 ])
692
- plt .polar ([3 , 4 ], [.3 , .4 ])
693
- assert len (fig .axes ) == 1 , 'More than one polar axes created.'
694
-
695
-
696
- @check_figures_equal ()
697
- def test_polar_wrap (fig_test , fig_ref ):
698
- ax = fig_test .add_subplot (projection = "polar" )
699
- ax .plot (np .deg2rad ([179 , - 179 ]), [0.2 , 0.1 ])
700
- ax .plot (np .deg2rad ([2 , - 2 ]), [0.2 , 0.1 ])
701
- ax = fig_ref .add_subplot (projection = "polar" )
702
- ax .plot (np .deg2rad ([179 , 181 ]), [0.2 , 0.1 ])
703
- ax .plot (np .deg2rad ([2 , 358 ]), [0.2 , 0.1 ])
704
-
705
-
706
- @check_figures_equal ()
707
- def test_polar_units_1 (fig_test , fig_ref ):
708
- import matplotlib .testing .jpl_units as units
709
- units .register ()
710
- xs = [30.0 , 45.0 , 60.0 , 90.0 ]
711
- ys = [1.0 , 2.0 , 3.0 , 4.0 ]
712
-
713
- plt .figure (fig_test .number )
714
- plt .polar ([x * units .deg for x in xs ], ys )
715
-
716
- ax = fig_ref .add_subplot (projection = "polar" )
717
- ax .plot (np .deg2rad (xs ), ys )
718
- ax .set (xlabel = "deg" )
719
-
720
-
721
- @check_figures_equal ()
722
- def test_polar_units_2 (fig_test , fig_ref ):
723
- import matplotlib .testing .jpl_units as units
724
- units .register ()
725
- xs = [30.0 , 45.0 , 60.0 , 90.0 ]
726
- xs_deg = [x * units .deg for x in xs ]
727
- ys = [1.0 , 2.0 , 3.0 , 4.0 ]
728
- ys_km = [y * units .km for y in ys ]
729
-
730
- plt .figure (fig_test .number )
731
- # test {theta,r}units.
732
- plt .polar (xs_deg , ys_km , thetaunits = "rad" , runits = "km" )
733
- assert isinstance (plt .gca ().get_xaxis ().get_major_formatter (),
734
- units .UnitDblFormatter )
735
-
736
- ax = fig_ref .add_subplot (projection = "polar" )
737
- ax .plot (np .deg2rad (xs ), ys )
738
- ax .xaxis .set_major_formatter (mticker .FuncFormatter ("{:.12}" .format ))
739
- ax .set (xlabel = "rad" , ylabel = "km" )
740
-
741
-
742
- @image_comparison (['polar_rmin' ], style = 'default' )
743
- def test_polar_rmin ():
744
- r = np .arange (0 , 3.0 , 0.01 )
745
- theta = 2 * np .pi * r
746
-
747
- fig = plt .figure ()
748
- ax = fig .add_axes ([0.1 , 0.1 , 0.8 , 0.8 ], polar = True )
749
- ax .plot (theta , r )
750
- ax .set_rmax (2.0 )
751
- ax .set_rmin (0.5 )
752
-
753
-
754
- @image_comparison (['polar_negative_rmin' ], style = 'default' )
755
- def test_polar_negative_rmin ():
756
- r = np .arange (- 3.0 , 0.0 , 0.01 )
757
- theta = 2 * np .pi * r
758
-
759
- fig = plt .figure ()
760
- ax = fig .add_axes ([0.1 , 0.1 , 0.8 , 0.8 ], polar = True )
761
- ax .plot (theta , r )
762
- ax .set_rmax (0.0 )
763
- ax .set_rmin (- 3.0 )
764
-
765
-
766
- @image_comparison (['polar_rorigin' ], style = 'default' )
767
- def test_polar_rorigin ():
768
- r = np .arange (0 , 3.0 , 0.01 )
769
- theta = 2 * np .pi * r
770
-
771
- fig = plt .figure ()
772
- ax = fig .add_axes ([0.1 , 0.1 , 0.8 , 0.8 ], polar = True )
773
- ax .plot (theta , r )
774
- ax .set_rmax (2.0 )
775
- ax .set_rmin (0.5 )
776
- ax .set_rorigin (0.0 )
777
-
778
-
779
- @image_comparison (['polar_invertedylim.png' ], style = 'default' )
780
- def test_polar_invertedylim ():
781
- fig = plt .figure ()
782
- ax = fig .add_axes ([0.1 , 0.1 , 0.8 , 0.8 ], polar = True )
783
- ax .set_ylim (2 , 0 )
784
-
785
-
786
- @image_comparison (['polar_invertedylim_rorigin.png' ], style = 'default' )
787
- def test_polar_invertedylim_rorigin ():
788
- fig = plt .figure ()
789
- ax = fig .add_axes ([0.1 , 0.1 , 0.8 , 0.8 ], polar = True )
790
- ax .set_ylim (2 , 0 )
791
- ax .set_rorigin (3 )
792
-
793
-
794
- @image_comparison (['polar_theta_position' ], style = 'default' )
795
- def test_polar_theta_position ():
796
- r = np .arange (0 , 3.0 , 0.01 )
797
- theta = 2 * np .pi * r
798
-
799
- fig = plt .figure ()
800
- ax = fig .add_axes ([0.1 , 0.1 , 0.8 , 0.8 ], polar = True )
801
- ax .plot (theta , r )
802
- ax .set_theta_zero_location ("NW" , 30 )
803
- ax .set_theta_direction ('clockwise' )
804
-
805
-
806
- @image_comparison (['polar_rlabel_position' ], style = 'default' )
807
- def test_polar_rlabel_position ():
808
- fig = plt .figure ()
809
- ax = fig .add_subplot (111 , projection = 'polar' )
810
- ax .set_rlabel_position (315 )
811
- ax .tick_params (rotation = 'auto' )
812
-
813
-
814
- @image_comparison (['polar_theta_wedge' ], style = 'default' )
815
- def test_polar_theta_limits ():
816
- r = np .arange (0 , 3.0 , 0.01 )
817
- theta = 2 * np .pi * r
818
-
819
- theta_mins = np .arange (15.0 , 361.0 , 90.0 )
820
- theta_maxs = np .arange (50.0 , 361.0 , 90.0 )
821
- DIRECTIONS = ('out' , 'in' , 'inout' )
822
-
823
- fig , axs = plt .subplots (len (theta_mins ), len (theta_maxs ),
824
- subplot_kw = {'polar' : True },
825
- figsize = (8 , 6 ))
826
-
827
- for i , start in enumerate (theta_mins ):
828
- for j , end in enumerate (theta_maxs ):
829
- ax = axs [i , j ]
830
- ax .plot (theta , r )
831
- if start < end :
832
- ax .set_thetamin (start )
833
- ax .set_thetamax (end )
834
- else :
835
- # Plot with clockwise orientation instead.
836
- ax .set_thetamin (end )
837
- ax .set_thetamax (start )
838
- ax .set_theta_direction ('clockwise' )
839
- ax .tick_params (tick1On = True , tick2On = True ,
840
- direction = DIRECTIONS [i % len (DIRECTIONS )],
841
- rotation = 'auto' )
842
- ax .yaxis .set_tick_params (label2On = True , rotation = 'auto' )
843
-
844
-
845
- @check_figures_equal (extensions = ["png" ])
846
- def test_polar_rlim (fig_test , fig_ref ):
847
- ax = fig_test .subplots (subplot_kw = {'polar' : True })
848
- ax .set_rlim (top = 10 )
849
- ax .set_rlim (bottom = .5 )
850
-
851
- ax = fig_ref .subplots (subplot_kw = {'polar' : True })
852
- ax .set_rmax (10. )
853
- ax .set_rmin (.5 )
854
-
855
-
856
- @check_figures_equal (extensions = ["png" ])
857
- def test_polar_rlim_bottom (fig_test , fig_ref ):
858
- ax = fig_test .subplots (subplot_kw = {'polar' : True })
859
- ax .set_rlim (bottom = [.5 , 10 ])
860
-
861
- ax = fig_ref .subplots (subplot_kw = {'polar' : True })
862
- ax .set_rmax (10. )
863
- ax .set_rmin (.5 )
864
-
865
-
866
- def test_polar_rlim_zero ():
867
- ax = plt .figure ().add_subplot (projection = 'polar' )
868
- ax .plot (np .arange (10 ), np .arange (10 ) + .01 )
869
- assert ax .get_ylim ()[0 ] == 0
870
-
871
-
872
600
@image_comparison (['aitoff_proj' ], extensions = ["png" ],
873
601
remove_text = True , style = 'mpl20' )
874
602
def test_aitoff_proj ():
@@ -2327,17 +2055,6 @@ def test_log_scales_invalid():
2327
2055
ax .set_ylim (- 1 , 10 )
2328
2056
2329
2057
2330
- def test_polar_no_data ():
2331
- plt .subplot (projection = "polar" )
2332
- ax = plt .gca ()
2333
- assert ax .get_rmin () == 0 and ax .get_rmax () == 1
2334
- plt .close ("all" )
2335
- # Used to behave differently (by triggering an autoscale with no data).
2336
- plt .polar ()
2337
- ax = plt .gca ()
2338
- assert ax .get_rmin () == 0 and ax .get_rmax () == 1
2339
-
2340
-
2341
2058
@image_comparison (['stackplot_test_image' , 'stackplot_test_image' ])
2342
2059
def test_stackplot ():
2343
2060
fig = plt .figure ()
@@ -4481,12 +4198,6 @@ def test_shared_with_aspect_3():
4481
4198
assert round (expected , 4 ) == round (ax .get_aspect (), 4 )
4482
4199
4483
4200
4484
- def test_polar_not_datalim_adjustable ():
4485
- ax = plt .figure ().add_subplot (projection = "polar" )
4486
- with pytest .raises (ValueError ):
4487
- ax .set_adjustable ("datalim" )
4488
-
4489
-
4490
4201
@pytest .mark .parametrize ('twin' , ('x' , 'y' ))
4491
4202
def test_twin_with_aspect (twin ):
4492
4203
fig , ax = plt .subplots ()
@@ -5723,22 +5434,6 @@ def test_zero_linewidth():
5723
5434
plt .plot ([0 , 1 ], [0 , 1 ], ls = '--' , lw = 0 )
5724
5435
5725
5436
5726
- def test_polar_gridlines ():
5727
- fig = plt .figure ()
5728
- ax = fig .add_subplot (111 , polar = True )
5729
-
5730
- # make all major grid lines lighter, only x grid lines set in 2.1.0
5731
- ax .grid (alpha = 0.2 )
5732
-
5733
- # hide y tick labels, no effect in 2.1.0
5734
- plt .setp (ax .yaxis .get_ticklabels (), visible = False )
5735
-
5736
- fig .canvas .draw ()
5737
-
5738
- assert ax .xaxis .majorTicks [0 ].gridline .get_alpha () == .2
5739
- assert ax .yaxis .majorTicks [0 ].gridline .get_alpha () == .2
5740
-
5741
-
5742
5437
def test_empty_errorbar_legend ():
5743
5438
fig , ax = plt .subplots ()
5744
5439
ax .errorbar ([], [], xerr = [], label = 'empty y' )
@@ -6227,14 +5922,6 @@ def test_minor_accountedfor():
6227
5922
bbspines [n * 2 ].bounds , targetbb .bounds , atol = 1e-2 )
6228
5923
6229
5924
6230
- def test_get_tightbbox_polar ():
6231
- fig , ax = plt .subplots (subplot_kw = {'projection' : 'polar' })
6232
- fig .canvas .draw ()
6233
- bb = ax .get_tightbbox (fig .canvas .get_renderer ())
6234
- assert_allclose (
6235
- bb .extents , [107.7778 , 29.2778 , 539.7847 , 450.7222 ], rtol = 1e-03 )
6236
-
6237
-
6238
5925
@check_figures_equal (extensions = ["png" ])
6239
5926
def test_axis_bool_arguments (fig_test , fig_ref ):
6240
5927
# Test if False and "off" give the same
@@ -6430,27 +6117,3 @@ def test_invisible_axes():
6430
6117
assert fig .canvas .inaxes ((200 , 200 )) is not None
6431
6118
ax .set_visible (False )
6432
6119
assert fig .canvas .inaxes ((200 , 200 )) is None
6433
-
6434
-
6435
- @check_figures_equal (extensions = ["png" ])
6436
- def test_polar_interpolation_steps_constant_r (fig_test , fig_ref ):
6437
- # Check that an extra half-turn doesn't make any difference -- modulo
6438
- # antialiasing, which we disable here.
6439
- p1 = (fig_test .add_subplot (121 , projection = "polar" )
6440
- .bar ([0 ], [1 ], 3 * np .pi , edgecolor = "none" ))
6441
- p2 = (fig_test .add_subplot (122 , projection = "polar" )
6442
- .bar ([0 ], [1 ], - 3 * np .pi , edgecolor = "none" ))
6443
- p3 = (fig_ref .add_subplot (121 , projection = "polar" )
6444
- .bar ([0 ], [1 ], 2 * np .pi , edgecolor = "none" ))
6445
- p4 = (fig_ref .add_subplot (122 , projection = "polar" )
6446
- .bar ([0 ], [1 ], - 2 * np .pi , edgecolor = "none" ))
6447
- for p in [p1 , p2 , p3 , p4 ]:
6448
- plt .setp (p , antialiased = False )
6449
-
6450
-
6451
- @check_figures_equal (extensions = ["png" ])
6452
- def test_polar_interpolation_steps_variable_r (fig_test , fig_ref ):
6453
- l , = fig_test .add_subplot (projection = "polar" ).plot ([0 , np .pi / 2 ], [1 , 2 ])
6454
- l .get_path ()._interpolation_steps = 100
6455
- fig_ref .add_subplot (projection = "polar" ).plot (
6456
- np .linspace (0 , np .pi / 2 , 101 ), np .linspace (1 , 2 , 101 ))
0 commit comments