使用函数:DataFrame.plot.
pie
(y=None, **kwds)
功能:生成饼图。
饼图是一个列中数字数据的比例表示。这个函数封装了指定栏目的matplotlib.pyplot.pie()。如果没有传递列引用,而subplots=True则为每个数值列独立地绘制饼图。
Parameters: | y : int or label, optional
**kwds
|
---|---|
Returns: | axes : matplotlib.axes.Axes or np.ndarray of them.
|
series = pd.Series(3 * np.random.rand(4), index=['a', 'b', 'c', 'd'], name='series')
series.plot.pie(figsize=(6, 6))
df = pd.DataFrame(3 * np.random.rand(4, 2), index=['a', 'b', 'c', 'd'], columns=['x', 'y'])
df.plot.pie(subplots=True, figsize=(8, 4))
series.plot.pie(labels=['AA', 'BB', 'CC', 'DD'], colors=['r', 'g', 'b', 'c'],
autopct='%.2f', fontsize=10, figsize=(6, 6))
饼图相对较为简单,只要传值,定义颜色,定义信息,定义大小即可。