@@ -878,22 +878,26 @@ def __init__(self, center, r, theta1, theta2, width=None, **kwargs):
878878 self .center = center
879879 self .r , self .width = r , width
880880 self .theta1 , self .theta2 = theta1 , theta2
881+ self ._patch_transform = transforms .IdentityTransform ()
882+ self ._recompute_path ()
881883
884+ def _recompute_path (self ):
882885 # 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 :
884887 theta1 , theta2 = 0 , 360
885888 connector = Path .MOVETO
886889 else :
890+ theta1 , theta2 = self .theta1 , self .theta2
887891 connector = Path .LINETO
888892
889893 # Form the outer ring
890894 arc = Path .arc (theta1 , theta2 )
891895
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
894898 # followed by a reversed and scaled inner ring
895899 v1 = arc .vertices
896- v2 = arc .vertices [::- 1 ] * float (r - width ) / r
900+ v2 = arc .vertices [::- 1 ] * float (self . r - self . width ) / self . r
897901 v = np .vstack ([v1 , v2 , v1 [0 , :], (0 , 0 )])
898902 c = np .hstack ([arc .codes , arc .codes , connector , Path .CLOSEPOLY ])
899903 c [len (arc .codes )] = connector
@@ -903,12 +907,33 @@ def __init__(self, center, r, theta1, theta2, width=None, **kwargs):
903907 c = np .hstack ([arc .codes , [connector , connector , Path .CLOSEPOLY ]])
904908
905909 # 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 )
908912 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
910933
911934 def get_path (self ):
935+ if self ._path is None :
936+ self ._recompute_path ()
912937 return self ._path
913938
914939
0 commit comments