我有以下数据集:
import matplotlib.pyplot as plotter
pieLabels = 'Asia', 'Africa', 'Europe', 'North America', 'South America', 'Australia'
populationShare = [5.69, 16, 9.94, 7.79, 5.68, 6.54]
制作馅饼:
figureObject, axesObject = plotter.subplots()
axesObject.pie(populationShare,
labels=pieLabels,
startangle=90)
axesObject.axis('equal')
plotter.show()
我想制作一个饼图,并在饼图的切片上打印人口总数的实际值。没有百分比。
最佳答案
尝试如下所示:
import matplotlib.pyplot as plotter
pieLabels = ['Asia', 'Africa', 'Europe', 'North America', 'South America', 'Australia']
populationShare = [5.69, 16, 9.94, 7.79, 5.68, 6.54]
figureObject, axesObject = plotter.subplots()
axesObject.pie(populationShare,
labels=pieLabels,
autopct=lambda p: '{:.2f}'.format(p * sum(populationShare) / 100),
startangle=90)
axesObject.axis('equal')
plotter.show()
关于python - 饼图切片上的行值python,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/55251132/