Black Lives Matter. Please consider donating to Black Girls Code today.
Dash HoloViews is now available! Check out the docs.

R plotly histogram marker custom colors

Hi,
I have data.frame d as source of histogram.

There are 1-4 parameters Par I’d like to show. Is it possible to assign defined palette to displayed Par?

p_color=c("#FF7900","#EA0A8E","#48227C","#34A734")
p_color <- setNames(p_color, c(“P1”, “P2”, “P3”,“P4”))

plot_ly(d)%>%
add_histogram(x = ~LEVEL,xbins=bins,histfunc=‘count’,name=~Par,marker = list(color=~p_color , opacity=0.6, line = list(width = 1, color = ‘#000000’)))%>%
layout(barmode = “overlay”, xaxis = list(range = c(-200, 0)))

This works fine:
plot_ly(…)%>%
add_histogram(x=P1$LEVEL,…marker=list(color="#FF7900"))%>%
add_histogram(x=P2$LEVEL,…marker=list(color="#EA0A8E"))%>%
layout(barmode = “overlay”, xaxis = list(range = c(-200, 0)))

Kind Regards
K.