3131
3232from mlab import meshgrid
3333from matplotlib import rcParams
34- from patches import Rectangle , Circle , Polygon , Wedge , bbox_artist
34+ from patches import Rectangle , Circle , Polygon , Wedge , Shadow , bbox_artist
3535from table import Table
3636from text import Text , _process_text_args
3737from transforms import Bbox , Point , Value , Affine , NonseparableTransformation
@@ -322,7 +322,7 @@ def __init__(self, fig, rect,
322322 # funcs used to format x and y - fall back on major formatters
323323 self .fmt_xdata = None
324324 self .fmt_ydata = None
325-
325+
326326 def set_figure (self , fig ):
327327 """
328328Set the Axes figure
@@ -1643,6 +1643,7 @@ def legend(self, *args, **kwargs):
16431643 handlelen = 0.05 # the length of the legend lines
16441644 handletextsep = 0.02 # the space between the legend line and legend text
16451645 axespad = 0.02 # the border between the axes and legend edge
1646+ shadow = False # if True, draw a shadow behind legend
16461647 """
16471648
16481649 def get_handles ():
@@ -1980,6 +1981,7 @@ def pcolor_classic(self, *args, **kwargs):
19801981 def pie (self , x , explode = None , labels = None ,
19811982 colors = ('b' , 'g' , 'r' , 'c' , 'm' , 'y' , 'k' , 'w' ),
19821983 autopct = None ,
1984+ shadow = False
19831985 ):
19841986 """
19851987Make a pie chart of array x. The fractional area of each wedge is
@@ -1999,6 +2001,8 @@ def pie(self, x, explode=None, labels=None,
19992001 the wedge. If it is a format string, the label will be fmt%pct.
20002002 If it is a function, it will be called
20012003
2004+ - shadow, if True, will draw a shadow beneath the pie.
2005+
20022006The pie chart will probably look best if the figure and axes are
20032007square. Eg,
20042008
@@ -2044,10 +2048,20 @@ def pie(self, x, explode=None, labels=None,
20442048
20452049 w = Wedge ((x ,y ), radius , 360. * theta1 , 360. * theta2 ,
20462050 facecolor = colors [i % len (colors )])
2047- slices .append (w )
2051+ slices .append (w )
20482052 self .add_patch (w )
20492053 self .set_label (label )
20502054
2055+ if shadow :
2056+ # make sure to add a shadow after the call to
2057+ # add_patch so the figure and transform props will be
2058+ # set
2059+ shad = Shadow (w , - 0.02 , - 0.02 ,
2060+ #props={'facecolor':w.get_facecolor()}
2061+ )
2062+ shad .set_zorder (0.9 * w .get_zorder ())
2063+ self .add_patch (shad )
2064+
20512065
20522066 xt = x + 1.1 * radius * math .cos (thetam )
20532067 yt = y + 1.1 * radius * math .sin (thetam )
0 commit comments