Skip to content

Clockwise pie diagram #2537

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
fat-crocodile opened this issue Oct 23, 2013 · 7 comments
Closed

Clockwise pie diagram #2537

fat-crocodile opened this issue Oct 23, 2013 · 7 comments
Milestone

Comments

@fat-crocodile
Copy link
Contributor

Hi! Please, add this feature. My diff in axes.py looks quite simple:

--- /home/sh/Downloads/matplotlib-1.3.1/lib/matplotlib/axes.py 2013-10-10 16:42:48.000000000 +0400
+++ matplotlib/axes.py  2013-10-23 16:52:11.793788510 +0400
@@ -5307,7 +5307,7 @@
 
     def pie(self, x, explode=None, labels=None, colors=None,
             autopct=None, pctdistance=0.6, shadow=False,
-            labeldistance=1.1, startangle=None, radius=None):
+            labeldistance=1.1, startangle=None, radius=None, counterclock=True):
         r"""
         Plot a pie chart.
 
@@ -5420,12 +5420,12 @@
         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,
+            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)
@mdboom
Copy link
Member

mdboom commented Oct 23, 2013

Can you add a regression test and a what's new entry?

@fat-crocodile
Copy link
Contributor Author

I think yes, if you give me a link to some tutorial. I am novice here and don't know what type of regression test you want, and what and where write about what's new (do you mean just add new input parameter in function comment?)

Back compatibility seems obvious, if counterclock is True, new code works just like old one.

@tacaswell
Copy link
Member

@fat-crocodile Have you been able to work in this? It would be nice to get this into 1.4.0.

@fat-crocodile
Copy link
Contributor Author

Your english is too good for me, sorry, I can not understand precisely what are you asking for.

This code works good in my project, diff looks quite simple. If I shall do something to help you include this code in 1.4.0, tell me please what shall I do.

@tacaswell
Copy link
Member

Do you know how to use git/github well enough to create a pull request?

There is a file in the documentation folder whats_new.rst which should have a description of this change added. For the test, basically copy one of the existing image tests.

If you can please make a pull request. If not then I will take care of this.

@fat-crocodile
Copy link
Contributor Author

#2853

@tacaswell
Copy link
Member

Closing this in favor of the open PR (#2853)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants