Python 饼图切片上的行值

Python 饼图切片上的行值,python,pandas,Python,Pandas,我有以下数据集: 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 = plott

我有以下数据集:

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()

我想制作一个饼图,并将populationShare的实际值打印在饼图的各个部分上。没有百分比。

尝试以下方法:

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()

{.0f)的作用是什么?语法无效,无法找出原因抱歉,我已更新了完整的代码。就您的数据而言,您需要使用{.2f}。这意味着您正在显示小数点后两位的值。请尝试代码,如果行得通,请接受我的答案。谢谢。@RedaS