@@ -1002,6 +1002,32 @@ def test_canonical():
10021002 ax .plot ([1 , 2 , 3 ])
10031003
10041004
1005+ @image_comparison (baseline_images = ['arc_angles' ], remove_text = True ,
1006+ style = 'default' , extensions = ['png' ])
1007+ def test_arc_angles ():
1008+ from matplotlib import patches
1009+ # Ellipse parameters
1010+ w = 2
1011+ h = 1
1012+ centre = (0.2 , 0.5 )
1013+
1014+ fig , axs = plt .subplots (3 , 3 )
1015+ for i , ax in enumerate (axs .flat ):
1016+ theta2 = i * 360 / 9
1017+ theta1 = theta2 - 45
1018+ ax .add_patch (patches .Ellipse (centre , w , h , alpha = 0.3 ))
1019+ ax .add_patch (patches .Arc (centre , w , h , theta1 = theta1 , theta2 = theta2 ))
1020+ # Straight lines intersecting start and end of arc
1021+ ax .plot ([2 * np .cos (np .deg2rad (theta1 )) + centre [0 ],
1022+ centre [0 ],
1023+ 2 * np .cos (np .deg2rad (theta2 )) + centre [0 ]],
1024+ [2 * np .sin (np .deg2rad (theta1 )) + centre [1 ],
1025+ centre [1 ],
1026+ 2 * np .sin (np .deg2rad (theta2 )) + centre [1 ]])
1027+ ax .set_xlim (- 2 , 2 )
1028+ ax .set_ylim (- 2 , 2 )
1029+
1030+
10051031@image_comparison (baseline_images = ['arc_ellipse' ],
10061032 remove_text = True )
10071033def test_arc_ellipse ():
@@ -1010,15 +1036,14 @@ def test_arc_ellipse():
10101036 width , height = 1e-1 , 3e-1
10111037 angle = - 30
10121038
1013- theta = np .arange (0.0 , 360.0 , 1.0 )* np .pi / 180.0
1014- x = width / 2. * np .cos (theta )
1015- y = height / 2. * np .sin (theta )
1039+ theta = np .arange (0.0 , 360.0 , 1.0 ) * np .pi / 180.0
1040+ x = width / 2. * np .cos (theta )
1041+ y = height / 2. * np .sin (theta )
10161042
1017- rtheta = angle * np .pi / 180.
1043+ rtheta = angle * np .pi / 180.
10181044 R = np .array ([
1019- [np .cos (rtheta ), - np .sin (rtheta )],
1020- [np .sin (rtheta ), np .cos (rtheta )],
1021- ])
1045+ [np .cos (rtheta ), - np .sin (rtheta )],
1046+ [np .sin (rtheta ), np .cos (rtheta )]])
10221047
10231048 x , y = np .dot (R , np .array ([x , y ]))
10241049 x += xcenter
0 commit comments