plotly.R
plotly.R copied to clipboard
Legend Color for Bar plot
trying to change the colors in a Bar plot, the colors of the legend are not coherent with the applied palette (they are black instead of the colors assigned to the markers)
This is a reproducible example
mtcars %>% plot_ly(x=rownames(mtcars),y=carb,type="bar",group=cyl,marker = list(color=as.character(factor(mtcars$cyl,levels=c("4","6","8"),labels=c("#D8D8D8","#51C439","#53BCD4")))))
Having the same issue
I think this code gives you the result you're looking for:
mtcars %>% plot_ly(
x = rownames(mtcars), y = carb, type = "bar",
color = factor(cyl), colors = c("#D8D8D8","#51C439","#53BCD4")
)

#872 still there in the new plotly version 4.5.2