Thanks to visit codestin.com
Credit goes to github.com

Skip to content

small bug in the mtplotlib gallery #18428

Closed
@Dan-Lt

Description

@Dan-Lt

The example with the "Labeling a pie and a donut" with the funcion :
def func(pct, allvals):
absolute = int(pct/100.*np.sum(allvals))
return "{:.1f}%\n({:d} g)".format(pct, absolute)
see the link:
https://matplotlib.org/3.1.1/gallery/pie_and_polar_charts/pie_and_donut_labels.html#sphx-glr-gallery-pie-and-polar-charts-pie-and-donut-labels-py

I'v found out that given a list of 1000 numbers you lose about 3% of the counts because the of the absolute, I think if you use round it will solve the problem: "absolute = int(round(pct/100.*np.sum(allvals)))

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions