我有以下数据要构建一个饼图
categories=['organic','cpc','referral']
proportions=[40.5,5.8,36.9]
所以我这么做了:
fig1, ax1 = plt.subplots()
labels = [f'{x} {np.round(y / sum(proportions) * 100, 1)}%' for x,y in dict(zip(categories, proportions)).items()]
ax1.pie(proportions, labels=labels, autopct='%1.1f%%', shadow=False, startangle=90, rotatelabels=True)
ax1.axis('equal')
fig1 = plt.gcf()
fig1.set_size_inches(7, 7)
circle = plt.Circle(xy=(0, 0), radius=0.75, facecolor='white')
plt.gca().add_artist(circle)
在饼的内侧,我得到了下面这些多余的值,我怎么才能去掉它们呢?我需要移除外侧支撑和内侧支撑的信息:
发布于 2020-11-11 21:19:38
用autopct=None
替换autopct='%1.1f%%'
发布于 2020-11-11 21:21:44
删除autopct='%1.1f%%',
就可以了
https://stackoverflow.com/questions/64787127
复制相似问题