【发布时间】:2017-11-14 16:00:59
【问题描述】:
我正在尝试创建一个饼图,如下:
import matplotlib.pyplot as plt
import pandas as pd
# make a square figure and axes
plt.figure(1, figsize=(10,10))
plt.axes([0.01, 0.1, 0.6, 0.6])
# plt.style.use('fivethirtyeight')
# The slices will be ordered and plotted counter-clockwise.
labels = 'foo1', 'foo2', 'foo3', 'foo4'
fracs = pd.Series([10,30, 50,10],index=labels)
fracs.plot(kind='pie', labels=None, autopct='%1.0f%%')
plt.legend(bbox_to_anchor=(0.95, .9), loc=2, borderaxespad=0.,labels=labels)
plt.title('pie chart demo which should be center aligned not left', bbox={'facecolor':'0.8', 'pad':5})
plt.show()
这是一个饼图: 但是,我面临两个问题: 1)我不喜欢配色方案。我想要一个更符合 的配色方案(我需要 12 种颜色) 2) 标题仅以饼图为中心。传说不知何故出来了。我正在尝试将标题置于图表和图例的中心。
有人可以帮忙吗?
【问题讨论】:
标签: python-3.x pandas matplotlib pie-chart