plotly.R icon indicating copy to clipboard operation
plotly.R copied to clipboard

Legend Color for Bar plot

Open federicou opened this issue 10 years ago • 3 comments

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")))))

federicou avatar Feb 15 '16 17:02 federicou

Having the same issue

shapenaji avatar Apr 06 '16 16:04 shapenaji

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")
)

rplot

cpsievert avatar Apr 06 '16 23:04 cpsievert

#872 still there in the new plotly version 4.5.2

kiezuz avatar Feb 07 '17 13:02 kiezuz