Plot a pie chart.
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 of x give the fractional area directly and the array will not be normalized. The resulting pie will have an empty wedge of size 1 - sum(x)
.
The wedges are plotted counterclockwise, by default starting from the x-axis.
The wedge sizes.
If not None, is a len(x)
array which specifies the fraction of the radius with which to offset each wedge.
A sequence of strings providing the labels for each wedge
A sequence of colors through which the pie chart will cycle. If None, will use the colors in the currently active cycle.
If not None, is a string or function used to label the wedges with their numeric value. The label will be placed inside the wedge. If it is a format string, the label will be fmt % pct
. If it is a function, it will be called.
The ratio between the center of each pie slice and the start of the text generated by autopct. Ignored if autopct is None.
Draw a shadow beneath the pie.
When True, always make a full pie by normalizing x so that sum(x) == 1
. False makes a partial pie if sum(x) <= 1
and raises a ValueError
for sum(x) > 1
.
The radial distance at which the pie labels are drawn. If set to None
, label are not drawn, but are stored for use in legend()
The angle by which the start of the pie is rotated, counterclockwise from the x-axis.
The radius of the pie.
Specify fractions direction, clockwise or counterclockwise.
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. By default clip_on=False
.
Dict of arguments to pass to the text objects.
The coordinates of the center of the chart.
Plot Axes frame with the chart if true.
Rotate each label to the angle of the corresponding slice if true.
If given, the following parameters also accept a string s
, which is interpreted as data[s]
(unless this raises an exception):
x, explode, labels, colors
A sequence of matplotlib.patches.Wedge
instances
A list of the label Text
instances.
A list of Text
instances for the numeric labels. This will only be returned if the parameter autopct is not None.
The pie chart will probably look best if the figure and Axes are square, or the Axes aspect is equal. This method sets the aspect ratio of the axis to "equal". The Axes aspect ratio can be controlled with Axes.set_aspect
.
matplotlib.axes.Axes.pie
© 2012–2021 Matplotlib Development Team. All rights reserved.
Licensed under the Matplotlib License Agreement.
https://matplotlib.org/3.5.1/api/_as_gen/matplotlib.axes.Axes.pie.html