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

Skip to content

Issue 2899 #2923

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Mar 27, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 8 additions & 2 deletions boilerplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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 = []
Expand Down
10 changes: 9 additions & 1 deletion doc/devel/coding_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Five years ago, in e91c5a1, I commented out the line that was making boilerplate look first in the local tree, without removing the comment that went with that line. I don't know why I did that. If the present behavior is what we want, then the first two lines in the excerpt from boilerplate, below, should be deleted. I suspect the present behavior makes sense because otherwise python code would be found in the source tree but compiled extensions would be from the installed version, so they could be out of sync.

# import the local copy of matplotlib, not the installed one
#sys.path.insert(0, './lib')
from matplotlib.axes import Axes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@efiring
Updated boilerplate.py with a better comment.

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.
8 changes: 8 additions & 0 deletions doc/users/whats_new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
-------------
Expand Down
31 changes: 26 additions & 5 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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
Expand Down Expand Up @@ -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.::

Expand Down Expand Up @@ -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 = []
Expand All @@ -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)
Expand All @@ -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)

Expand All @@ -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
Expand Down
6 changes: 4 additions & 2 deletions lib/matplotlib/pyplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
Expand Down
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading