【发布时间】:2021-04-16 20:45:50
【问题描述】:
我正在学习使用 matplotlib 可视化,并且正在做一个简单的饼图。我想知道为什么当我绘制这个时,百分比如下:
我原以为它会显示 40% 的青蛙和 50% 的猪...
我需要标准化吗?
labels = 'Frogs', 'Hogs'
sizes = [40,50]
#explode = (0, 0.1, 0, 0) # only "explode" the 2nd slice (i.e. 'Hogs')
fig1, ax1 = plt.subplots()
ax1.pie(sizes,labels=labels, autopct='%1.1f%%')
ax1.axis('equal') # Equal aspect ratio ensures that pie is drawn as a circle.
plt.show()
【问题讨论】:
-
40/90 = 44.4%.... 50/90 = 55.6%
标签: python matplotlib data-visualization pie-chart