I am creating a simple Plotly bar plot with following data, where the color of the individual Bars will be varying based on the respective values of the Bar. However range of the color should be defined i.e. ranging from Blue (smallest) to Red (highest)
df <- data.frame(x = c('a', 'B'),
y = c(100, 50),
z = c(100, 50))
plot_ly(data = df,
x = ~x,
y = ~y,
marker = list(color = ~z),
colors = c("blue", "red"),
type = "bar")
Unfortunately Plotly displays Bar chart with something different Color-scheme. Could you please point me the right code .
Thanks in advance