plotly / plotly/plotly.R

Bug: ggplotly ignores colours in ggplot2::scale_fill_gradientn when limits are below the range of the data

Offen
#606 3 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

bug ggplotly
Vorherrschende Sprache
R
Sterne
2.7k
Forks
641
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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:
image

Plot in plotly (see the wrong colors produced!)
image

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Führe zunächst das eigenständige R-Beispiel mit ggplot2, viridis und plotly aus und vergleiche anschließend die Farbausgabe von ggplot2 und ggplotly, wenn die Grenzen von scale_fill_gradientn unterhalb des Datenbereichs liegen. Als erledigt gilt die Aufgabe, wenn ggplotly in diesem Fall die beabsichtigten Farben des Farbverlaufs beibehält.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
r
Bereich
data-visualization
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.