Been trying to figure out a fix but not sure if there’s an easy way to do this.
plot_ly appears to allow color scales for scatter plots, so that higher values are colored differently. Is there a way to apply a similar color scale to a plot_ly bar graph?
For instance, if I wanted bars with values closer to 1 colored green, but values closer to 0 colored as red, would that be possible with the “color” argument?
Found a work-around with ggplotly. Still seems impossible with base plot_ly command.
a <- ggplot(test.players, aes(x = Player,
y = Average.Points,
fill = Average.Points)
)
b <- a + geom_bar(stat = "identity")
c <- b + scale_fill_gradientn(colors = c("red", "green"))
ggplotly(c)