marvy
1
Is it possible to change the names in the legend without changing the columnames of the dataframe ?
import pandas as pd
import numpy as np
import plotly.express as px
df = pd.DataFrame({"DateTime": pd.date_range(start="2021-12-08", end="2021-12-12")})
df["A"] = np.random.randint(0, 10, size=len(df))
df["B"] = np.random.randint(0, 5, size=len(df))
fig = px.bar(df, x='DateTime', y=['A','B'],title="Title",barmode='relative')
fig.show()
AIMPED
2
HI @marvy, you could change the names manually like so:
fig.update_traces({'name': 'trace 1, aka A'}, selector={'name': 'A'})
fig.update_traces({'name': 'trace 2, aka B'}, selector={'name': 'B'})
creates:
1 Like
marvy
3
Is there a way to do this using lists ? [βAβ,βBβ]
AIMPED
4
Hi @marvy, I donβt understand your question.