Open
Description
This is an odd bug (reported first as a heatmaply issue).
If we create a ggplot2 object with colors based on scale_fill_gradientn, then ggplotly respect the colors. But if the limits are set to be within (instead of outside) the range of the data, then ggplotly stops respecting the colors. This may be some fallback for how to deal with NA colors (but I don't know enough about ggplotly to know for sure).
Here is a self contained example:
library(ggplot2)
library(viridis)
library(plotly)
# Equivalent fill scales do the same job for the fill aesthetic
p <- ggplot(faithfuld, aes(waiting, eruptions)) +
geom_raster(aes(fill = density)) +
scale_fill_gradientn(colours = viridis(10), limits = c(0.001,.01))
p
ggplotly(p)