[matplotlib-devel] Patch to let specify pie chart text radius

2006-07-18 Thread Asheesh Laroia
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.


It works with the pylab interface because pylab.pie passes kwargs through.

I would love it if this were accepted into the main tarball; I hereby 
place this patch into the public domain, so there are no copyright 
restrictions on incorporating it into the matplotlib distribution.


Comments/questions welcome.  I'm subscribed to matplotlib-devel.

-- Asheesh.

--
It is easy to find fault, if one has that disposition.  There was once a man
who, not being able to find any other fault with his coal, complained that
there were too many prehistoric toads in it.
-- Mark Twain, "Pudd'nhead Wilson's Calendar"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.py2006-06-24 00:37:48.0 
-0700
+++ matplotlib-0.87.4.new/lib/matplotlib/axes.py2006-07-18 
16:54:15.0 -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
-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


[matplotlib-devel] svn bugs

2006-07-18 Thread John Hunter

I recently screwed up some of the swig wrappers in trying to hunt down
a memory leak, so if you get segfaults with recent mpl builds, it's my
fault. I think I've fixed the problem, so if you encounter errors,
make sure you are using revision 2581 or later and do a clean rebuild
if necessary by rm -rf ing the build subdir.  

Let me know if you see any strangeness...

JDH

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel