Change names in legend using

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 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 =, x='DateTime', y=['A','B'],title="Title",barmode='relative')


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'})

newplot (39)

1 Like

Is there a way to do this using lists ? [β€˜A’,β€˜B’]

Hi @marvy, I don’t understand your question.