diff --git a/CHANGELOG b/CHANGELOG
index e521a8815286..c75a56dcd7a4 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,7 @@
+2014-03-22 Added the keyword arguments wedgeprops and textprops to pie.
+ Users can control the wedge and text properties of the pie
+ in more detail, if they choose.
+
2014-03-17 Bug was fixed in append_axes from the AxesDivider class would not
append axes in the right location with respect to the reference
locator axes
diff --git a/boilerplate.py b/boilerplate.py
index a7e59fa16ce7..5bcbf03f741a 100644
--- a/boilerplate.py
+++ b/boilerplate.py
@@ -28,8 +28,7 @@
import textwrap
-# import the local copy of matplotlib, not the installed one
-#sys.path.insert(0, './lib')
+# this line imports the installed copy of matplotlib, and not the local copy
from matplotlib.axes import Axes
@@ -217,6 +216,13 @@ def format_value(value):
args.pop(0) # remove 'self' argument
if defaults is None:
defaults = ()
+ else:
+ def_edited = []
+ for val in defaults:
+ if isinstance(val, unicode):
+ val = val.encode('ascii', 'ignore')
+ def_edited.append(val)
+ defaults = tuple(def_edited)
# How to call the wrapped function
call = []
diff --git a/doc/devel/coding_guide.rst b/doc/devel/coding_guide.rst
index 2df6a8cb636d..bf7e55a35dd8 100644
--- a/doc/devel/coding_guide.rst
+++ b/doc/devel/coding_guide.rst
@@ -277,8 +277,16 @@ Writing a new pyplot function
-----------------------------
A large portion of the pyplot interface is automatically generated by the
-`boilerplate.py` script (in the root of the source tree). To add or remove
+`boilerplate.py` script (in the root of the source tree). To add or remove
a plotting method from pyplot, edit the appropriate list in `boilerplate.py`
and then run the script which will update the content in
`lib/matplotlib/pyplot.py`. Both the changes in `boilerplate.py` and
`lib/matplotlib/pyplot.py` should be checked into the repository.
+
+Note: boilerplate.py looks for changes in the installed version of matplotlib
+and not the source tree. If you expect the pyplot.py file to show your new
+changes, but they are missing, this might be the cause.
+
+Install your new files by running `python setup.py build` and `python setup.py
+install` followed by `python boilerplate.py`. The new pyplot.py file should now
+have the latest changes.
diff --git a/doc/users/whats_new.rst b/doc/users/whats_new.rst
index 49685ec4fd88..341ac381c617 100644
--- a/doc/users/whats_new.rst
+++ b/doc/users/whats_new.rst
@@ -131,6 +131,14 @@ specifically the Skew-T used in meteorology.
.. plot:: mpl_examples/api/skewt.py
+Support for specifying properties of wedge and text in pie charts.
+``````````````````````````````````````````````````````````````
+Added the `kwargs` 'wedgeprops' and 'textprops' to :func:`~matplotlib.Axes.pie`
+to accept properties for wedge and text objects in a pie. For example, one can
+specify wedgeprops = {'linewidth':3} to specify the width of the borders of
+the wedges in the pie. For more properties that the user can specify, look at
+the docs for the wedge and text objects.
+
Date handling
-------------
diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py
index 022b6c2a53fb..6b8ad4549ad8 100644
--- a/lib/matplotlib/axes/_axes.py
+++ b/lib/matplotlib/axes/_axes.py
@@ -2336,7 +2336,8 @@ def stem(self, *args, **kwargs):
def pie(self, x, explode=None, labels=None, colors=None,
autopct=None, pctdistance=0.6, shadow=False, labeldistance=1.1,
- startangle=None, radius=None, counterclock=True):
+ startangle=None, radius=None, counterclock=True,
+ wedgeprops=None, textprops=None):
r"""
Plot a pie chart.
@@ -2345,7 +2346,9 @@ def pie(self, x, explode=None, labels=None, colors=None,
pie(x, explode=None, labels=None,
colors=('b', 'g', 'r', 'c', 'm', 'y', 'k', 'w'),
autopct=None, pctdistance=0.6, shadow=False,
- labeldistance=1.1, startangle=None, radius=None)
+ labeldistance=1.1, startangle=None, radius=None,
+ counterclock=True, wedgeprops=None, textprops=None,
+ )
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
@@ -2393,6 +2396,15 @@ def pie(self, x, explode=None, labels=None, colors=None,
*counterclock*: [ *False* | *True* ]
Specify fractions direction, clockwise or counterclockwise.
+ *wedgeprops*: [ *None* | dict of key value pairs ]
+ Dict of arguments passed to the wedge objects making the pie.
+ For example, you can pass in wedgeprops = { 'linewidth' : 3 }
+ to set the width of the wedge border lines equal to 3.
+ For more details, look at the doc/arguments of the wedge object.
+
+ *textprops*: [ *None* | dict of key value pairs ]
+ Dict of arguments to pass to the text objects.
+
The pie chart will probably look best if the figure and axes are
square, or the Axes aspect is equal. e.g.::
@@ -2445,6 +2457,11 @@ def pie(self, x, explode=None, labels=None, colors=None,
else:
theta1 = startangle / 360.0
+ if wedgeprops is None:
+ wedgeprops = {}
+ if textprops is None:
+ textprops = {}
+
texts = []
slices = []
autotexts = []
@@ -2459,7 +2476,8 @@ def pie(self, x, explode=None, labels=None, colors=None,
w = mpatches.Wedge((x, y), radius, 360. * min(theta1, theta2),
360. * max(theta1, theta2),
- facecolor=colors[i % len(colors)])
+ facecolor=colors[i % len(colors)],
+ **wedgeprops)
slices.append(w)
self.add_patch(w)
w.set_label(label)
@@ -2483,7 +2501,8 @@ def pie(self, x, explode=None, labels=None, colors=None,
t = self.text(xt, yt, label,
size=rcParams['xtick.labelsize'],
horizontalalignment=label_alignment,
- verticalalignment='center')
+ verticalalignment='center',
+ **textprops)
texts.append(t)
@@ -2500,7 +2519,9 @@ def pie(self, x, explode=None, labels=None, colors=None,
t = self.text(xt, yt, s,
horizontalalignment='center',
- verticalalignment='center')
+ verticalalignment='center',
+ **textprops)
+
autotexts.append(t)
theta1 = theta2
diff --git a/lib/matplotlib/pyplot.py b/lib/matplotlib/pyplot.py
index 12480b43552a..da553fe212c6 100644
--- a/lib/matplotlib/pyplot.py
+++ b/lib/matplotlib/pyplot.py
@@ -3046,7 +3046,8 @@ def phase_spectrum(x, Fs=None, Fc=None, window=None, pad_to=None, sides=None,
@_autogen_docstring(Axes.pie)
def pie(x, explode=None, labels=None, colors=None, autopct=None,
pctdistance=0.6, shadow=False, labeldistance=1.1, startangle=None,
- radius=None, hold=None):
+ radius=None, counterclock=True, wedgeprops=None, textprops=None,
+ hold=None):
ax = gca()
# allow callers to override the hold state by passing hold=True|False
washold = ax.ishold()
@@ -3057,7 +3058,8 @@ def pie(x, explode=None, labels=None, colors=None, autopct=None,
ret = ax.pie(x, explode=explode, labels=labels, colors=colors,
autopct=autopct, pctdistance=pctdistance, shadow=shadow,
labeldistance=labeldistance, startangle=startangle,
- radius=radius)
+ radius=radius, counterclock=counterclock,
+ wedgeprops=wedgeprops, textprops=textprops)
draw_if_interactive()
finally:
ax.hold(washold)
diff --git a/lib/matplotlib/tests/baseline_images/test_axes/pie_linewidth_0.pdf b/lib/matplotlib/tests/baseline_images/test_axes/pie_linewidth_0.pdf
new file mode 100644
index 000000000000..abb48a5aa37c
Binary files /dev/null and b/lib/matplotlib/tests/baseline_images/test_axes/pie_linewidth_0.pdf differ
diff --git a/lib/matplotlib/tests/baseline_images/test_axes/pie_linewidth_0.png b/lib/matplotlib/tests/baseline_images/test_axes/pie_linewidth_0.png
new file mode 100644
index 000000000000..79665aadd8e9
Binary files /dev/null and b/lib/matplotlib/tests/baseline_images/test_axes/pie_linewidth_0.png differ
diff --git a/lib/matplotlib/tests/baseline_images/test_axes/pie_linewidth_0.svg b/lib/matplotlib/tests/baseline_images/test_axes/pie_linewidth_0.svg
new file mode 100644
index 000000000000..1f4b40e54230
--- /dev/null
+++ b/lib/matplotlib/tests/baseline_images/test_axes/pie_linewidth_0.svg
@@ -0,0 +1,523 @@
+
+
+
+
diff --git a/lib/matplotlib/tests/baseline_images/test_axes/pie_linewidth_2.pdf b/lib/matplotlib/tests/baseline_images/test_axes/pie_linewidth_2.pdf
new file mode 100644
index 000000000000..c841170a4881
Binary files /dev/null and b/lib/matplotlib/tests/baseline_images/test_axes/pie_linewidth_2.pdf differ
diff --git a/lib/matplotlib/tests/baseline_images/test_axes/pie_linewidth_2.png b/lib/matplotlib/tests/baseline_images/test_axes/pie_linewidth_2.png
new file mode 100644
index 000000000000..b0ac34e88ded
Binary files /dev/null and b/lib/matplotlib/tests/baseline_images/test_axes/pie_linewidth_2.png differ
diff --git a/lib/matplotlib/tests/baseline_images/test_axes/pie_linewidth_2.svg b/lib/matplotlib/tests/baseline_images/test_axes/pie_linewidth_2.svg
new file mode 100644
index 000000000000..89b63616405d
--- /dev/null
+++ b/lib/matplotlib/tests/baseline_images/test_axes/pie_linewidth_2.svg
@@ -0,0 +1,523 @@
+
+
+
+
diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py
index 7a2d600804ab..7bc3471d0efa 100644
--- a/lib/matplotlib/tests/test_axes.py
+++ b/lib/matplotlib/tests/test_axes.py
@@ -2884,6 +2884,36 @@ def test_text_labelsize():
ax.tick_params(direction='out')
+@image_comparison(baseline_images=['pie_linewidth_0'])
+def test_pie_linewidth_0():
+ # The slices will be ordered and plotted counter-clockwise.
+ labels = 'Frogs', 'Hogs', 'Dogs', 'Logs'
+ sizes = [15, 30, 45, 10]
+ colors = ['yellowgreen', 'gold', 'lightskyblue', 'lightcoral']
+ explode = (0, 0.1, 0, 0) # only "explode" the 2nd slice (i.e. 'Hogs')
+
+ plt.pie(sizes, explode=explode, labels=labels, colors=colors,
+ autopct='%1.1f%%', shadow=True, startangle=90,
+ wedgeprops={'linewidth': 0})
+ # Set aspect ratio to be equal so that pie is drawn as a circle.
+ plt.axis('equal')
+
+
+@image_comparison(baseline_images=['pie_linewidth_2'])
+def test_pie_linewidth_2():
+ # The slices will be ordered and plotted counter-clockwise.
+ labels = 'Frogs', 'Hogs', 'Dogs', 'Logs'
+ sizes = [15, 30, 45, 10]
+ colors = ['yellowgreen', 'gold', 'lightskyblue', 'lightcoral']
+ explode = (0, 0.1, 0, 0) # only "explode" the 2nd slice (i.e. 'Hogs')
+
+ plt.pie(sizes, explode=explode, labels=labels, colors=colors,
+ autopct='%1.1f%%', shadow=True, startangle=90,
+ wedgeprops={'linewidth': 2})
+ # Set aspect ratio to be equal so that pie is drawn as a circle.
+ plt.axis('equal')
+
+
if __name__ == '__main__':
import nose
import sys