@@ -878,22 +878,26 @@ def __init__(self, center, r, theta1, theta2, width=None, **kwargs):
878
878
self .center = center
879
879
self .r , self .width = r , width
880
880
self .theta1 , self .theta2 = theta1 , theta2
881
+ self ._patch_transform = transforms .IdentityTransform ()
882
+ self ._recompute_path ()
881
883
884
+ def _recompute_path (self ):
882
885
# Inner and outer rings are connected unless the annulus is complete
883
- if abs ((theta2 - theta1 ) - 360 ) <= 1e-12 :
886
+ if abs ((self . theta2 - self . theta1 ) - 360 ) <= 1e-12 :
884
887
theta1 , theta2 = 0 , 360
885
888
connector = Path .MOVETO
886
889
else :
890
+ theta1 , theta2 = self .theta1 , self .theta2
887
891
connector = Path .LINETO
888
892
889
893
# Form the outer ring
890
894
arc = Path .arc (theta1 , theta2 )
891
895
892
- if width is not None :
893
- # Partial annulus needs to draw the outter ring
896
+ if self . width is not None :
897
+ # Partial annulus needs to draw the outer ring
894
898
# followed by a reversed and scaled inner ring
895
899
v1 = arc .vertices
896
- v2 = arc .vertices [::- 1 ] * float (r - width ) / r
900
+ v2 = arc .vertices [::- 1 ] * float (self . r - self . width ) / self . r
897
901
v = np .vstack ([v1 , v2 , v1 [0 , :], (0 , 0 )])
898
902
c = np .hstack ([arc .codes , arc .codes , connector , Path .CLOSEPOLY ])
899
903
c [len (arc .codes )] = connector
@@ -903,12 +907,33 @@ def __init__(self, center, r, theta1, theta2, width=None, **kwargs):
903
907
c = np .hstack ([arc .codes , [connector , connector , Path .CLOSEPOLY ]])
904
908
905
909
# Shift and scale the wedge to the final location.
906
- v *= r
907
- v += np .asarray (center )
910
+ v *= self . r
911
+ v += np .asarray (self . center )
908
912
self ._path = Path (v , c )
909
- self ._patch_transform = transforms .IdentityTransform ()
913
+
914
+ def set_center (self , center ):
915
+ self ._path = None
916
+ self .center = center
917
+
918
+ def set_radius (self , radius ):
919
+ self ._path = None
920
+ self .radius = radius
921
+
922
+ def set_theta1 (self , theta1 ):
923
+ self ._path = None
924
+ self .theta1 = theta1
925
+
926
+ def set_theta2 (self , theta2 ):
927
+ self ._path = None
928
+ self .theta2 = theta2
929
+
930
+ def set_width (self , width ):
931
+ self ._path = None
932
+ self .width = width
910
933
911
934
def get_path (self ):
935
+ if self ._path is None :
936
+ self ._recompute_path ()
912
937
return self ._path
913
938
914
939
0 commit comments