diff --git a/CHANGELOG b/CHANGELOG index b6e7611bd37e..e6f161149105 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +2014-03-13 Add parameter 'clockwise' to function pie, True by default. + 2014-27-02 Implemented separate horizontal/vertical axes padding to the ImageGrid in the AxesGrid toolkit diff --git a/doc/api/api_changes.rst b/doc/api/api_changes.rst index 4520735f709f..640e9a082bca 100644 --- a/doc/api/api_changes.rst +++ b/doc/api/api_changes.rst @@ -144,6 +144,8 @@ original location: tuple-like if separate axis padding is required. The original behavior is preserved. +* Added clockwise parameter to control sectors direction in `axes.pie` + .. _changes_in_1_3: diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 90d9b4f2d714..9474852a5c96 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -2339,8 +2339,8 @@ def stem(self, *args, **kwargs): return stem_container def pie(self, x, explode=None, labels=None, colors=None, - autopct=None, pctdistance=0.6, shadow=False, - labeldistance=1.1, startangle=None, radius=None): + autopct=None, pctdistance=0.6, shadow=False, labeldistance=1.1, + startangle=None, radius=None, counterclock=True): r""" Plot a pie chart. @@ -2394,6 +2394,9 @@ def pie(self, x, explode=None, labels=None, colors=None, *radius*: [ *None* | scalar ] The radius of the pie, if *radius* is *None* it will be set to 1. + *counterclock*: [ *False* | *True* ] + Specify fractions direction, clockwise or counterclockwise. + The pie chart will probably look best if the figure and axes are square, or the Axes aspect is equal. e.g.:: @@ -2453,13 +2456,14 @@ def pie(self, x, explode=None, labels=None, colors=None, i = 0 for frac, label, expl in cbook.safezip(x, labels, explode): x, y = center - theta2 = theta1 + frac + theta2 = (theta1 + frac) if counterclock else (theta1 - frac) thetam = 2 * math.pi * 0.5 * (theta1 + theta2) x += expl * math.cos(thetam) y += expl * math.sin(thetam) - w = mpatches.Wedge((x, y), radius, 360. * theta1, 360. * theta2, - facecolor=colors[i % len(colors)]) + w = mpatches.Wedge((x, y), radius, 360. * min(theta1, theta2), + 360. * max(theta1, theta2), + facecolor=colors[i % len(colors)]) slices.append(w) self.add_patch(w) w.set_label(label)
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: