Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7fb1c98

Browse files
committed
Add startangle as argument to pie charts
1 parent 79f3650 commit 7fb1c98

3 files changed

Lines changed: 20 additions & 5 deletions

File tree

CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2012-05-04 Add a new argument to pie charts - startingangle - that
2+
allows one to specify the angle offset to the first wedge
3+
of the chart. - EP
4+
15
2012-04-06 When path clipping changes a LINETO to a MOVETO, it also
26
changes any CLOSEPOLY command to a LINETO to the initial
37
point. This fixes a problem with pdf and svg where the

lib/matplotlib/axes.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5005,13 +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):
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
@@ -5048,6 +5049,10 @@ def pie(self, x, explode=None, labels=None, colors=None,
50485049
*shadow*: [ *False* | *True* ]
50495050
Draw a shadow beneath the pie.
50505051
5052+
*startangle*: [ *None* | Offset angle ]
5053+
If not *None*, rotates the start of the pie chart by *angle*
5054+
degrees.
5055+
50515056
The pie chart will probably look best if the figure and axes are
50525057
square. Eg.::
50535058
@@ -5085,8 +5090,14 @@ def pie(self, x, explode=None, labels=None, colors=None,
50855090

50865091
center = 0,0
50875092
radius = 1
5088-
theta1 = 0
50895093
i = 0
5094+
5095+
# Starting theta1 is the start fraction of the circle
5096+
if startangle is None:
5097+
theta1 = 0
5098+
else:
5099+
theta1 = startangle / 360.0
5100+
50905101
texts = []
50915102
slices = []
50925103
autotexts = []

lib/matplotlib/pyplot.py

Lines changed: 2 additions & 2 deletions
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)