Renaming labels in Pie chart

I am trying to rename the labels in plotly express Pie chart but somehow it is not changing.
Any help would be appreciated.


 fig = px.pie(
        labels={1: "Success", 0: "Unsuccess"},
    return fig

Screenshot of Pie Chart:

@adamschroeder @empet @nicolaskruchten any help here guys?

Hi @matsujju
Let’s see what others say, but I don’t think you can rename them because they are traces. You can only rename labels.
If you want to rename traces, you would have to change those values inside the dataframe columns, using Pandas.

Will wait for others to reply…
thanks for reply.

Hi @matsujju! Please refrain from tagging other users in your threads unless they’ve previously replied to the same thread… empet and adamschroeder are some of the busiest users on the forum and they probably don’t need the extra notifications :slight_smile:

In this case there are no built-in PX features for changing the data in your data frame (which is where the 0 and 1 come from)… PX can only change the labels on when the come from column names in your data frame. This means that @adamschroeder is right: you’ll have to change the underlying data in this case.

1 Like

Sorry will definitely try not to tag individual person but this community is not as responsive as it should be. I only tag individual (here experts) if the question asked doesn’t get a reply in 24 hrs and I think that is probably good enough time. Moreover, I also see there are many questions on Stackoverflow respect to plotly python/ Dash which were unanswered since months and sometime even year. As a beginner myself and others it is very difficult to get along in this library/package where small mistakes matters to move forward and if people don’t get answer to their question, how will they learn and help others and in the end will leave this community and might try other visualization library which is more open source than enterprise.

Hi @matsujju
Thank you for your feedback. Ideally everyone would have an answer to their responses. We try our best to keep up with all the questions, however, there are many more questions than people have time to answer currently. Hopefully, this will improve as more people become Dash Plotly experts.
And hopefully one day you too can become a powerful user of Dash and contribute to the challenges of an open source community.

Good luck with your coding 🙅🏽

1 Like