hi all, I have the following code, im wanting to make a legend like this from
def SetColor(y):
if(y <= 1):
return “red”
elif(y <= 3):
return “yellow”
elif(y <= 5):
return “green”
customscale=[[1, “rgb(255, 0, 0)”],
[2, “rgb(255, 0, 0)”],
[3, “rgb(0, 0, 255)”],
[4, “rgb(0, 0, 255)”]]
@app.callback(
Output(component_id=“chart”, component_property=“figure”),
Input(component_id=“option”, component_property=“value”))
def on_option(option):
filtered_df = df[(df[“Class1”]==option) | (df[“Class2”]==option) | (df[“Class3”]==option) | (df[“Class4”]==option) | (df[“Class5”]==option)]
return px.bar(filtered_df, x=filtered_df[“ID”], y=filtered_df[“score”]) #color=dict(list(map(SetColor, filtered_df[‘score’])))) #color_continuous_scale=“Viridis”, range_color=(0, 7))
cannot seem to work this out… can this be done with plotly express??