Skip to content

Commit b24824d

Browse files
committed
Merge branch 'epeisach-pie_angle'
2 parents 23e335b + 6a0c448 commit b24824d

File tree

4 files changed

+46
-23
lines changed

4 files changed

+46
-23
lines changed

CHANGELOG

+12-8
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
2012-05-22 Collections now have a setting "offset_position" to select whether
2-
the offsets are given in "screen" coordinates (default,
3-
following the old behavior) or "data" coordinates. This is currently
4-
used internally to improve the performance of hexbin.
2+
the offsets are given in "screen" coordinates (default,
3+
following the old behavior) or "data" coordinates. This is currently
4+
used internally to improve the performance of hexbin.
55

6-
As a result, the "draw_path_collection" backend methods have grown
7-
a new argument "offset_position". - MGD
6+
As a result, the "draw_path_collection" backend methods have grown
7+
a new argument "offset_position". - MGD
8+
9+
2012-05-04 Add a new argument to pie charts - startingangle - that
10+
allows one to specify the angle offset to the first wedge
11+
of the chart. - EP
812

913
2012-05-03 symlog scale now obeys the logarithmic base. Previously, it was
10-
completely ignored and always treated as base e. - MGD
14+
completely ignored and always treated as base e. - MGD
1115

1216
2012-05-03 Allow linscalex/y keyword to symlog scale that allows the size of
13-
the linear portion relative to the logarithmic portion to be
14-
adjusted. - MGD
17+
the linear portion relative to the logarithmic portion to be
18+
adjusted. - MGD
1519

1620
2012-04-06 When path clipping changes a LINETO to a MOVETO, it also
1721
changes any CLOSEPOLY command to a LINETO to the initial

examples/pylab_examples/pie_demo.py

+12-7
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33
http://matplotlib.sf.net/matplotlib.pylab.html#-pie for the docstring.
44
55
This example shows a basic pie chart with labels optional features,
6-
like autolabeling the percentage, offsetting a slice with "explode"
7-
and adding a shadow.
8-
9-
Requires matplotlib0-0.70 or later
6+
like autolabeling the percentage, offsetting a slice with "explode",
7+
adding a shadow, and changing the starting angle.
108
119
"""
1210
from pylab import *
@@ -15,11 +13,18 @@
1513
figure(1, figsize=(6,6))
1614
ax = axes([0.1, 0.1, 0.8, 0.8])
1715

16+
# The slices will be ordered and plotted counter-clockwise.
1817
labels = 'Frogs', 'Hogs', 'Dogs', 'Logs'
19-
fracs = [15,30,45, 10]
20-
18+
fracs = [15, 30, 45, 10]
2119
explode=(0, 0.05, 0, 0)
22-
pie(fracs, explode=explode, labels=labels, autopct='%1.1f%%', shadow=True)
20+
21+
pie(fracs, explode=explode, labels=labels,
22+
autopct='%1.1f%%', shadow=True, startangle=90)
23+
# The default startangle is 0, which would start
24+
# the Frogs slice on the x-axis. With startangle=90,
25+
# everything is rotated counter-clockwise by 90 degrees,
26+
# so the plotting starts on the positive y-axis.
27+
2328
title('Raining Hogs and Dogs', bbox={'facecolor':'0.8', 'pad':5})
2429

2530
show()

lib/matplotlib/axes.py

+20-6
Original file line numberDiff line numberDiff line change
@@ -5005,18 +5005,20 @@ 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):
5008+
labeldistance=1.1, startangle=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, shadow=False)
5014+
autopct=None, pctdistance=0.6, labeldistance=1.1,
5015+
shadow=False, startangle=None)
50155016
50165017
Make a pie chart of array *x*. The fractional area of each
50175018
wedge is given by x/sum(x). If sum(x) <= 1, then the values
50185019
of x give the fractional area directly and the array will not
5019-
be normalized.
5020+
be normalized. The wedges are plotted counterclockwise,
5021+
by default starting from the x-axis.
50205022
50215023
Keyword arguments:
50225024
@@ -5048,6 +5050,10 @@ def pie(self, x, explode=None, labels=None, colors=None,
50485050
*shadow*: [ *False* | *True* ]
50495051
Draw a shadow beneath the pie.
50505052
5053+
*startangle*: [ *None* | Offset angle ]
5054+
If not *None*, rotates the start of the pie chart by *angle*
5055+
degrees counterclockwise from the x-axis.
5056+
50515057
The pie chart will probably look best if the figure and axes are
50525058
square. Eg.::
50535059
@@ -5085,8 +5091,14 @@ def pie(self, x, explode=None, labels=None, colors=None,
50855091

50865092
center = 0,0
50875093
radius = 1
5088-
theta1 = 0
50895094
i = 0
5095+
5096+
# Starting theta1 is the start fraction of the circle
5097+
if startangle is None:
5098+
theta1 = 0
5099+
else:
5100+
theta1 = startangle / 360.0
5101+
50905102
texts = []
50915103
slices = []
50925104
autotexts = []
@@ -5151,8 +5163,10 @@ def pie(self, x, explode=None, labels=None, colors=None,
51515163
self.set_xticks([])
51525164
self.set_yticks([])
51535165

5154-
if autopct is None: return slices, texts
5155-
else: return slices, texts, autotexts
5166+
if autopct is None:
5167+
return slices, texts
5168+
else:
5169+
return slices, texts, autotexts
51565170

51575171
@docstring.dedent_interpd
51585172
def errorbar(self, x, y, yerr=None, xerr=None,

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.59999999999999998, shadow=False, labeldistance=1.1000000000000001, hold=None):
2445+
def pie(x, explode=None, labels=None, colors=None, autopct=None, pctdistance=0.6, shadow=False, labeldistance=1.1, startangle=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)
2453+
ret = ax.pie(x, explode, labels, colors, autopct, pctdistance, shadow, labeldistance, startangle)
24542454
draw_if_interactive()
24552455
finally:
24562456
ax.hold(washold)

0 commit comments

Comments
 (0)