I have a Shiny app with several plotly visualisations. The user is allowed to choose several products and I would like each product to have the same unique color throughout the entire app. One of my visualisations could e.g. look like this:
plot_ly(df, x = variable, y=value, type = “bar”, color = Product, hoverinfo = “text”,
colors = colpal, text = paste0(df$value,"%")) %>%
layout(xaxis=ax, yaxis=yx, legend=list(x=1, y = 0.5))
Is is possible to make sure that the first level of Product ALWAYS get the first value of colpal?
In ggplot I think this can be achieved by specifying the color pallette like this:
c(“Product A” = “#00AADC”, “Product B” = “#843532”,“Product C” = “#2C5481”, “Product D” = “#CADFE1”)
But this doesnt seem to work in plotly.
Any help would be greatly appreciated.