Plotly Express rename legend/variable

3k views Asked by At

How to rename the variables (i.e. "fiber","protein","potass") in the legend and also in the hover text? screenshot here

fig=px.scatter(df,x=["fiber","protein","potass"],y="rating",trendline="ols",
           labels={"rating":"Rating (%)"},
           hover_name="name")

These three variables have their own columns, which is why the x data is a list.

I've tried editing the labels but it didn't change anything in the plot.

1

There are 1 answers

0
Mihir Thakur On

You can change the legend item names as answered here.

I am not clear with the labels issue you are encountering. Could you share the code for that if possible or clarify more about the problem.

All I could find was the official doc. I may be able to help you if you can provide sample code for your problem.