Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plot.pie() autopct shows 0.00 for 0/None data #33707

Open
filipopo opened this issue Apr 21, 2020 · 2 comments
Open

plot.pie() autopct shows 0.00 for 0/None data #33707

filipopo opened this issue Apr 21, 2020 · 2 comments
Labels
Bug Needs Discussion Requires discussion from core team before further action Visualization plotting

Comments

@filipopo
Copy link

filipopo commented Apr 21, 2020

Not sure should I report this upstream to matplotlib to be honest but
The label correctly does not appear but the percent does,

percents = pd.Series(
    data = [
        0, # the same for None
        10
    ],
    index = [
        'nothing',
        'label'
    ],
    name = 'plot'
)

percents.plot.pie(autopct = '%.2f')

Output:
madzijaplot

@filipopo filipopo added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Apr 21, 2020
@jbrockmendel jbrockmendel added Visualization plotting and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Jun 5, 2020
@mzeitlin11
Copy link
Member

Thanks for the report @filip98! This does not look like an upstream issue - labels with 0 are explicitly blanked out on the pandas end before matplotlib plotting functions are called:

def blank_labeler(label, value):
if value == 0:
return ""
else:
return label
idx = [pprint_thing(v) for v in self.data.index]
labels = kwds.pop("labels", idx)
# labels is used for each wedge's labels
# Blank out labels for values of 0 so they don't overlap
# with nonzero wedges

The reason for this looks to be to avoid label overlap as happens with matplotlib:

data = [0, 0, 10]
labels = "aaa", "bbb", "label"
fig1, ax1 = plt.subplots()
ax1.pie(data, labels=labels, autopct='%.2f')

gives
Screen Shot 2020-12-23 at 4 35 00 PM

@mzeitlin11 mzeitlin11 added Needs Discussion Requires discussion from core team before further action and removed Bug labels Dec 23, 2020
@filipopo
Copy link
Author

Hey mzeitlin11,

I would expect matplotlib to not show that as well tbh.

@mroeschke mroeschke added the Bug label Jul 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Needs Discussion Requires discussion from core team before further action Visualization plotting
Projects
None yet
Development

No branches or pull requests

4 participants