Skip to content

Clockwise pie diagram #2537

@fat-crocodile

Description

@fat-crocodile

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      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:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy