Skip to content

Commit f093e22

Browse files
committed
Merge branch 'BigPieSmallPie' of https://github.com/HubertHolin/matplotlib into HubertHolin-BigPieSmallPie
Conflicts: lib/matplotlib/axes.py lib/matplotlib/pyplot.py string.diff
2 parents b24824d + 40be30a commit f093e22

File tree

5 files changed

+63
-7
lines changed

5 files changed

+63
-7
lines changed

doc/api/api_changes.rst

+7
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ help figure out possible sources of the changes you are experiencing.
1111
For new features that were added to matplotlib, please see
1212
:ref:`whats-new`.
1313

14+
Changes in 1.2.x
15+
================
16+
17+
* In :meth:`~matplotlib.pyplot.pie` and :meth:`~matplotlib.Axes.pie`, one can
18+
now set the radius of the pie; setting the *radius* to 'None' (the default
19+
value), will result in a pie with a radius of 1 as before.
20+
1421
Changes in 1.1.x
1522
================
1623

examples/pylab_examples/pie_demo2.py

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
"""
2+
Make a pie charts of varying size - see
3+
http://matplotlib.sf.net/matplotlib.pylab.html#-pie for the docstring.
4+
5+
This example shows a basic pie charts with labels optional features,
6+
like autolabeling the percentage, offsetting a slice with "explode"
7+
and adding a shadow, in different sizes.
8+
9+
"""
10+
from pylab import *
11+
from matplotlib.gridspec import GridSpec
12+
13+
# Some data
14+
15+
labels = 'Frogs', 'Hogs', 'Dogs', 'Logs'
16+
fracs = [15,30,45, 10]
17+
18+
explode=(0, 0.05, 0, 0)
19+
20+
# Make square figures and axes
21+
22+
the_grid = GridSpec(2, 2)
23+
24+
figure(1, figsize=(6,6))
25+
26+
subplot(the_grid[0, 0])
27+
28+
pie(fracs, labels=labels, autopct='%1.1f%%', shadow=True)
29+
30+
subplot(the_grid[0, 1])
31+
32+
pie(fracs, explode=explode, labels=labels, autopct='%1.1f%%', shadow=True)
33+
34+
subplot(the_grid[1, 0])
35+
36+
pie(fracs, labels=labels, autopct='%1.1f%%', shadow=True, radius=0.5)
37+
38+
subplot(the_grid[1, 1])
39+
40+
pie(fracs, explode=explode, labels=labels, autopct='%1.1f%%', shadow=True,
41+
radius=0.5)
42+
43+
show()

examples/tests/backend_driver.py

+1
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@
161161
'pcolor_log.py',
162162
'pcolor_small.py',
163163
'pie_demo.py',
164+
'pie_demo2.py',
164165
'plotfile_demo.py',
165166
'polar_bar.py',
166167
'polar_demo.py',

lib/matplotlib/axes.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -5005,14 +5005,14 @@ def stem(self, x, y, linefmt='b-', markerfmt='bo', basefmt='r-',
50055005

50065006
def pie(self, x, explode=None, labels=None, colors=None,
50075007
autopct=None, pctdistance=0.6, shadow=False,
5008-
labeldistance=1.1, startangle=None):
5008+
labeldistance=1.1, startangle=None, radius=None):
50095009
r"""
50105010
Call signature::
50115011
50125012
pie(x, explode=None, labels=None,
50135013
colors=('b', 'g', 'r', 'c', 'm', 'y', 'k', 'w'),
5014-
autopct=None, pctdistance=0.6, labeldistance=1.1,
5015-
shadow=False, startangle=None)
5014+
autopct=None, pctdistance=0.6, shadow=False,
5015+
labeldistance=1.1, startangle=None, radius=None)
50165016
50175017
Make a pie chart of array *x*. The fractional area of each
50185018
wedge is given by x/sum(x). If sum(x) <= 1, then the values
@@ -5054,6 +5054,9 @@ def pie(self, x, explode=None, labels=None, colors=None,
50545054
If not *None*, rotates the start of the pie chart by *angle*
50555055
degrees counterclockwise from the x-axis.
50565056
5057+
*radius*: [ *None* | scalar ]
5058+
The radius of the pie, if *radius* is *None* it will be set to 1.
5059+
50575060
The pie chart will probably look best if the figure and axes are
50585061
square. Eg.::
50595062
@@ -5090,8 +5093,8 @@ def pie(self, x, explode=None, labels=None, colors=None,
50905093

50915094

50925095
center = 0,0
5093-
radius = 1
5094-
i = 0
5096+
if radius is None:
5097+
radius = 1
50955098

50965099
# Starting theta1 is the start fraction of the circle
50975100
if startangle is None:
@@ -5102,6 +5105,8 @@ def pie(self, x, explode=None, labels=None, colors=None,
51025105
texts = []
51035106
slices = []
51045107
autotexts = []
5108+
5109+
i = 0
51055110
for frac, label, expl in cbook.safezip(x,labels, explode):
51065111
x, y = center
51075112
theta2 = theta1 + frac

lib/matplotlib/pyplot.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2442,15 +2442,15 @@ def pcolormesh(*args, **kwargs):
24422442
# This function was autogenerated by boilerplate.py. Do not edit as
24432443
# changes will be lost
24442444
@autogen_docstring(Axes.pie)
2445-
def pie(x, explode=None, labels=None, colors=None, autopct=None, pctdistance=0.6, shadow=False, labeldistance=1.1, startangle=None, hold=None):
2445+
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):
24462446
ax = gca()
24472447
# allow callers to override the hold state by passing hold=True|False
24482448
washold = ax.ishold()
24492449

24502450
if hold is not None:
24512451
ax.hold(hold)
24522452
try:
2453-
ret = ax.pie(x, explode, labels, colors, autopct, pctdistance, shadow, labeldistance, startangle)
2453+
ret = ax.pie(x, explode, labels, colors, autopct, pctdistance, shadow, labeldistance, startangle, radius)
24542454
draw_if_interactive()
24552455
finally:
24562456
ax.hold(washold)

0 commit comments

Comments
 (0)