On Tue, 18 Jul 2006, Asheesh Laroia wrote:

For pie charts, autopct lets a format string with the pie's value be printed on the chart. The default fraction of the radius that the text is printed at is 0.6; I wanted the text farther out at 0.85.

This small patch (against matplotlib 0.87.4) allows one to customize that radius by a new keyword argument, pctradius. The old behavior is still the default.

This patch does not change default behavior but provides a useful feature enhancement that we use at Creative Commons. It would be great if you, our humble upstream, would accept it in the new point release. Would you?

Thanks! I'm subscribed to matplotlib-devel and welcome comments. I've re-attached the patch in the case that it got lost.

-- Asheesh.

--
You are a bundle of energy, always on the go.
diff -urN matplotlib-0.87.4/lib/matplotlib/axes.py 
matplotlib-0.87.4.new/lib/matplotlib/axes.py
--- matplotlib-0.87.4/lib/matplotlib/axes.py    2006-06-24 00:37:48.000000000 
-0700
+++ matplotlib-0.87.4.new/lib/matplotlib/axes.py        2006-07-18 
16:54:15.000000000 -0700
@@ -2638,12 +2638,13 @@
     def pie(self, x, explode=None, labels=None,
             colors=None,
             autopct=None,
+            pctdistance=0.6,
             shadow=False
             ):
         """
         PIE(x, explode=None, labels=None,
             colors=('b', 'g', 'r', 'c', 'm', 'y', 'k', 'w'),
-            autopct=None, shadow=False)
+            autopct=None, pctdistance=0.6, shadow=False)
 
         Make a pie chart of array x.  The fractional area of each wedge is
         given by x/sum(x).  If sum(x)<=1, then the values of x give the
@@ -2662,6 +2663,10 @@
             the wedge.  If it is a format string, the label will be fmt%pct.
             If it is a function, it will be called
 
+          - pctdistance is the ratio between the center of each pie slice
+            and the start of the text generated by autopct.  Ignored if autopct
+            is None; default is 0.6.
+
           - shadow, if True, will draw a shadow beneath the pie.
 
         The pie chart will probably look best if the figure and axes are
@@ -2736,8 +2741,8 @@
             texts.append(t)
 
             if autopct is not None:
-                xt = x + 0.6*radius*math.cos(thetam)
-                yt = y + 0.6*radius*math.sin(thetam)
+                xt = x + pctdistance*radius*math.cos(thetam)
+                yt = y + pctdistance*radius*math.sin(thetam)
                 if is_string_like(autopct):
                     s = autopct%(100.*frac)
                 elif callable(autopct):
Binary files matplotlib-0.87.4/lib/matplotlib/axes.pyc and 
matplotlib-0.87.4.new/lib/matplotlib/axes.pyc differ
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to