I would like to color each bar according to the value on a red scale. For example, the largest bar would be black rgb(0,0,0), the smallest would be rgb(80,0,0) and the intermediate ones would vary in intensity.
The link below has a solution in python, I would like to do it in re and using plotly
Changing color scale in seaborn bar plot
library(plotly)
city <- c("Paris", "New York", "Rio", "Salvador", "Curitiba", "Natal")
value <- c(10,20,30,10,10,10)
data <- data.frame(city, value, stringsAsFactors = FALSE)
data <- data[order(-data$value, data$city),]
data$city <- factor(data$city, levels = unique(data$city)[order(data$value, decreasing = FALSE)])
fig <- plot_ly(y = reorder(data$city,-data$value), x = data$value, type = "bar", orientation = 'h') %>% layout(yaxis = list(autorange = "reversed"))
fig