Bug: ggplotly ignores colours in ggplot2::scale_fill_gradientn when limits are below the range of the data
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- R
- Estrellas
- 2.7k
- Forks
- 641
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
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)
Plot in ggplot2:

Plot in plotly (see the wrong colors produced!)

Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Empieza ejecutando el ejemplo autocontenido de R con ggplot2, viridis y plotly, y compara después la salida de colores de ggplot2 y ggplotly cuando los límites de scale_fill_gradientn están por debajo del rango de datos. Se considera terminado cuando ggplotly conserva los colores previstos del degradado en este caso.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- r
- Área
- data-visualization
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bien especificado
- Aptitud para principiantes
- 35/100