8000 Merge branch 'fat-crocodile-counterclock' · matplotlib/matplotlib@af7198c · GitHub
[go: up one dir, main page]

Skip to content

Commit af7198c

Browse files
committed
Merge branch 'fat-crocodile-counterclock'
Conflicts: doc/api/api_changes.rst fixed conflict in api_changes.rst
2 parents d1b13d9 + 4d374d5 commit af7198c

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
2014-03-13 Add parameter 'clockwise' to function pie, True by default.
2+
13
2014-27-02 Implemented separate horizontal/vertical axes padding to the
24
ImageGrid in the AxesGrid toolkit
35

doc/api/api_changes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ original location:
147147
* Added support for skewed transforms to `matplotlib.transforms.Affine2D`,
148148
which can be created using the `skew` and `skew_deg` methods.
149149

150+
* Added clockwise parameter to control sectors direction in `axes.pie`
151+
150152

151153
.. _changes_in_1_3:
152154

lib/matplotlib/axes/_axes.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2335,8 +2335,8 @@ def stem(self, *args, **kwargs):
23352335
return stem_container
23362336

23372337
def pie(self, x, explode=None, labels=None, colors=None,
2338-
autopct=None, pctdistance=0.6, shadow=False,
2339-
labeldistance=1.1, startangle=None, radius=None):
2338+
autopct=None, pctdistance=0.6, shadow=False, labeldistance=1.1,
2339+
startangle=None, radius=None, counterclock=True):
23402340
r"""
23412341
Plot a pie chart.
23422342
@@ -2390,6 +2390,9 @@ def pie(self, x, explode=None, labels=None, colors=None,
23902390
*radius*: [ *None* | scalar ]
23912391
The radius of the pie, if *radius* is *None* it will be set to 1.
23922392
2393+
*counterclock*: [ *False* | *True* ]
2394+
Specify fractions direction, clockwise or counterclockwise.
2395+
23932396
The pie chart will probably look best if the figure and axes are
23942397
square, or the Axes aspect is equal. e.g.::
23952398
@@ -2449,13 +2452,14 @@ def pie(self, x, explode=None, labels=None, colors=None,
24492452
i = 0
24502453
for frac, label, expl in cbook.safezip(x, labels, explode):
24512454
x, y = center
2452-
theta2 = theta1 + frac
2455+
theta2 = (theta1 + frac) if counterclock else (theta1 - frac)
24532456
thetam = 2 * math.pi * 0.5 * (theta1 + theta2)
24542457
x += expl * math.cos(thetam)
24552458
y += expl * math.sin(thetam)
24562459

2457-
w = mpatches.Wedge((x, y), radius, 360. * theta1, 360. * theta2,
2458-
facecolor=colors[i % len(colors)])
2460+
w = mpatches.Wedge((x, y), radius, 360. * min(theta1, theta2),
2461+
360. * max(theta1, theta2),
2462+
facecolor=colors[i % len(colors)])
24592463
slices.append(w)
24602464
self.add_patch(w)
24612465
w.set_label(label)

0 commit comments

Comments
 (0)
0