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

Skip to content

Commit be33461

Browse files
committed
Merge pull request #2923 from sfroid/issue_2899
Issue 2899
2 parents 7d6d594 + 3523760 commit be33461

13 files changed

+1135
-10
lines changed

CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2014-03-22 Added the keyword arguments wedgeprops and textprops to pie.
2+
Users can control the wedge and text properties of the pie
3+
in more detail, if they choose.
4+
15
2014-03-17 Bug was fixed in append_axes from the AxesDivider class would not
26
append axes in the right location with respect to the reference
37
locator axes

boilerplate.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@
2828

2929
import textwrap
3030

31-
# import the local copy of matplotlib, not the installed one
32-
#sys.path.insert(0, './lib')
31+
# this line imports the installed copy of matplotlib, and not the local copy
3332
from matplotlib.axes import Axes
3433

3534

@@ -217,6 +216,13 @@ def format_value(value):
217216
args.pop(0) # remove 'self' argument
218217
if defaults is None:
219218
defaults = ()
219+
else:
220+
def_edited = []
221+
for val in defaults:
222+
if isinstance(val, unicode):
223+
val = val.encode('ascii', 'ignore')
224+
def_edited.append(val)
225+
defaults = tuple(def_edited)
220226

221227
# How to call the wrapped function
222228
call = []

doc/devel/coding_guide.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,16 @@ Writing a new pyplot function
277277
-----------------------------
278278

279279
A large portion of the pyplot interface is automatically generated by the
280-
`boilerplate.py` script (in the root of the source tree). To add or remove
280+
`boilerplate.py` script (in the root of the source tree). To add or remove
281281
a plotting method from pyplot, edit the appropriate list in `boilerplate.py`
282282
and then run the script which will update the content in
283283
`lib/matplotlib/pyplot.py`. Both the changes in `boilerplate.py` and
284284
`lib/matplotlib/pyplot.py` should be checked into the repository.
285+
286+
Note: boilerplate.py looks for changes in the installed version of matplotlib
287+
and not the source tree. If you expect the pyplot.py file to show your new
288+
changes, but they are missing, this might be the cause.
289+
290+
Install your new files by running `python setup.py build` and `python setup.py
291+
install` followed by `python boilerplate.py`. The new pyplot.py file should now
292+
have the latest changes.

doc/users/whats_new.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,14 @@ specifically the Skew-T used in meteorology.
131131

132132
.. plot:: mpl_examples/api/skewt.py
133133

134+
Support for specifying properties of wedge and text in pie charts.
135+
``````````````````````````````````````````````````````````````
136+
Added the `kwargs` 'wedgeprops' and 'textprops' to :func:`~matplotlib.Axes.pie`
137+
to accept properties for wedge and text objects in a pie. For example, one can
138+
specify wedgeprops = {'linewidth':3} to specify the width of the borders of
139+
the wedges in the pie. For more properties that the user can specify, look at
140+
the docs for the wedge and text objects.
141+
134142

135143
Date handling
136144
-------------

lib/matplotlib/axes/_axes.py

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2336,7 +2336,8 @@ def stem(self, *args, **kwargs):
23362336

23372337
def pie(self, x, explode=None, labels=None, colors=None,
23382338
autopct=None, pctdistance=0.6, shadow=False, labeldistance=1.1,
2339-
startangle=None, radius=None, counterclock=True):
2339+
startangle=None, radius=None, counterclock=True,
2340+
wedgeprops=None, textprops=None):
23402341
r"""
23412342
Plot a pie chart.
23422343
@@ -2345,7 +2346,9 @@ def pie(self, x, explode=None, labels=None, colors=None,
23452346
pie(x, explode=None, labels=None,
23462347
colors=('b', 'g', 'r', 'c', 'm', 'y', 'k', 'w'),
23472348
autopct=None, pctdistance=0.6, shadow=False,
2348-
labeldistance=1.1, startangle=None, radius=None)
2349+
labeldistance=1.1, startangle=None, radius=None,
2350+
counterclock=True, wedgeprops=None, textprops=None,
2351+
)
23492352
23502353
Make a pie chart of array *x*. The fractional area of each
23512354
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,
23932396
*counterclock*: [ *False* | *True* ]
23942397
Specify fractions direction, clockwise or counterclockwise.
23952398
2399+
*wedgeprops*: [ *None* | dict of key value pairs ]
2400+
Dict of arguments passed to the wedge objects making the pie.
2401+
For example, you can pass in wedgeprops = { 'linewidth' : 3 }
2402+
to set the width of the wedge border lines equal to 3.
2403+
For more details, look at the doc/arguments of the wedge object.
2404+
2405+
*textprops*: [ *None* | dict of key value pairs ]
2406+
Dict of arguments to pass to the text objects.
2407+
23962408
The pie chart will probably look best if the figure and axes are
23972409
square, or the Axes aspect is equal. e.g.::
23982410
@@ -2445,6 +2457,11 @@ def pie(self, x, explode=None, labels=None, colors=None,
24452457
else:
24462458
theta1 = startangle / 360.0
24472459

2460+
if wedgeprops is None:
2461+
wedgeprops = {}
2462+
if textprops is None:
2463+
textprops = {}
2464+
24482465
texts = []
24492466
slices = []
24502467
autotexts = []
@@ -2459,7 +2476,8 @@ def pie(self, x, explode=None, labels=None, colors=None,
24592476

24602477
w = mpatches.Wedge((x, y), radius, 360. * min(theta1, theta2),
24612478
360. * max(theta1, theta2),
2462-
facecolor=colors[i % len(colors)])
2479+
facecolor=colors[i % len(colors)],
2480+
**wedgeprops)
24632481
slices.append(w)
24642482
self.add_patch(w)
24652483
w.set_label(label)
@@ -2483,7 +2501,8 @@ def pie(self, x, explode=None, labels=None, colors=None,
24832501
t = self.text(xt, yt, label,
24842502
size=rcParams['xtick.labelsize'],
24852503
horizontalalignment=label_alignment,
2486-
verticalalignment='center')
2504+
verticalalignment='center',
2505+
**textprops)
24872506

24882507
texts.append(t)
24892508

@@ -2500,7 +2519,9 @@ def pie(self, x, explode=None, labels=None, colors=None,
25002519

25012520
t = self.text(xt, yt, s,
25022521
horizontalalignment='center',
2503-
verticalalignment='center')
2522+
verticalalignment='center',
2523+
**textprops)
2524+
25042525
autotexts.append(t)
25052526

25062527
theta1 = theta2

lib/matplotlib/pyplot.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3046,7 +3046,8 @@ def phase_spectrum(x, Fs=None, Fc=None, window=None, pad_to=None, sides=None,
30463046
@_autogen_docstring(Axes.pie)
30473047
def pie(x, explode=None, labels=None, colors=None, autopct=None,
30483048
pctdistance=0.6, shadow=False, labeldistance=1.1, startangle=None,
3049-
radius=None, hold=None):
3049+
radius=None, counterclock=True, wedgeprops=None, textprops=None,
3050+
hold=None):
30503051
ax = gca()
30513052
# allow callers to override the hold state by passing hold=True|False
30523053
washold = ax.ishold()
@@ -3057,7 +3058,8 @@ def pie(x, explode=None, labels=None, colors=None, autopct=None,
30573058
ret = ax.pie(x, explode=explode, labels=labels, colors=colors,
30583059
autopct=autopct, pctdistance=pctdistance, shadow=shadow,
30593060
labeldistance=labeldistance, startangle=startangle,
3060-
radius=radius)
3061+
radius=radius, counterclock=counterclock,
3062+
wedgeprops=wedgeprops, textprops=textprops)
30613063
draw_if_interactive()
30623064
finally:
30633065
ax.hold(washold)
Binary file not shown.

0 commit comments

Comments
 (0)