Movatterモバイル変換


[0]ホーム

URL:


Skip to main content
Ctrl+K

pandas.DataFrame.plot.pie#

DataFrame.plot.pie(**kwargs)[source]#

Generate a pie plot.

A pie plot is a proportional representation of the numerical data in acolumn. This function wrapsmatplotlib.pyplot.pie() for thespecified column. If no column reference is passed andsubplots=True a pie plot is drawn for each numerical columnindependently.

Parameters:
yint or label, optional

Label or position of the column to plot.If not provided,subplots=True argument must be passed.

**kwargs

Keyword arguments to pass on toDataFrame.plot().

Returns:
matplotlib.axes.Axes or np.ndarray of them

A NumPy array is returned whensubplots is True.

See also

Series.plot.pie

Generate a pie plot for a Series.

DataFrame.plot

Make plots of a DataFrame.

Examples

In the example below we have a DataFrame with the information aboutplanet’s mass and radius. We pass the ‘mass’ column to thepie function to get a pie plot.

>>>df=pd.DataFrame({'mass':[0.330,4.87,5.97],...'radius':[2439.7,6051.8,6378.1]},...index=['Mercury','Venus','Earth'])>>>plot=df.plot.pie(y='mass',figsize=(5,5))
../../_images/pandas-DataFrame-plot-pie-1.png
>>>plot=df.plot.pie(subplots=True,figsize=(11,6))
../../_images/pandas-DataFrame-plot-pie-2.png

[8]ページ先頭

©2009-2025 Movatter.jp