R Plotly change color of stacked bar chart

Viewed 4485

I have a Plotly stacked bar plot. I'd like to change the colors of the bars so I have Red and Dark Blue instead of the default colors you see below

enter image description here

My code below. I tried using the marker function but it converts the whole plot to a single color. Any help would be appreciated.

pie_subsegment_split %>%
plot_ly(x = ~Segment, y = ~Not*100, type = 'bar', name = 'Not') %>%
add_trace(y = ~QoL*100, name = 'QoL') %>%
layout(yaxis = list(title = 'Percentage (%)'),barmode = "stack",showlegend=T) %>%
layout(xaxis = list(title="Sub-Segment",showticklabels=FALSE))
1 Answers
Related