Is there a way to display the label of categories in px.pie?

Hello everyone,

I’m developping an application with Dash and I noticed this:

I have the label (title) of my categories on the px.bar, but not in the px.pie. I looked at the Plotly Express website and I did not find a pie chart with a label.

So I’m just wondering if this is possible, and, if yes, how?

My two codes:

fig_1 = px.bar(tmp_graph_6, x="Catégorie", y="Impact (%)", color="Catégorie", title='Impact par étapes du cycle de vie (%)')
 
fig_2 = px.pie(tmp_graph_4, values="Percentage", names='Ingredients', title='Impact par ingrédient (%)')

Thank you very much!

Alpy

Hi @Alpy,

I don’t know why it doesn’t show by default in a pie chart by you can just add the legend title manually:

fig_2.update_layout(legend_title='Catégorie')

Salut, Alex-

That seems like a bug we should fix, I’ll try to get it into the next release :slight_smile:

See https://github.com/plotly/plotly.py/issues/2966 for follow-up.

Thank you very much @Alexboiboi, it’s working just fine. Thank you also @nicolaskruchten, I’ll try it on the next release. : )