plotly / plotly/plotly.R

Mapping alpha to continuous variable in geom_tile()/geom_raster()

Offen
#1,579 2 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

I am trying to convert a heatmap I created with ggplot to a plotly object. Everything works fine, except no matter what I do, it won't translate the alpha values (I have tried both having it as aes- what I want- but also giving it a random value and it won't work. This is the ggplot code and output, which works fine:

I have tried both geom tile and geom raster and none of them seem to work.

 plot <- datos%>%
    ggplot(aes(Var2, Var1, fill = value,  alpha = dum,
text = paste("<b>Edad:</b>", Var2, "<br>",
                                                    "<b>Año:</b>", Var1, "<br>",
                                                    "<b> Año de nacimiento: </b>", (Var1 - Var2), "<br>",
                                                    "<b>Renta relativa:</b>", format(value, 
                                                                              big.mark = ".", 
                                                                              scientific = FALSE, 
                                                                              digits = 2))))+
  geom_raster()+
  scale_alpha(range = c(0.6, 1))+
  scale_x_continuous(breaks = seq(20, 75, by = 5), limits = c(20, 80))+
  scale_y_continuous(breaks = seq(2008, 2016, by = 2 ), limits = c(2008, 2016))+
  theme_minimal()

ggplot output (with a little more formatting:
image

ggplotly output (just doing ggplotly(plot)):
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

Beginne damit, das bereitgestellte Beispiel mit ggplotly(plot) zu reproduzieren, und vergleiche geom_raster() und geom_tile() sowie sowohl gemappte als auch feste alpha-Werte. Verfolge den ggplotly-Konvertierungspfad für die alpha-Ästhetik und überprüfe das Ergebnis anhand der ursprünglichen ggplot-Ausgabe. Erledigt ist die Aufgabe, wenn kontinuierliche alpha-Werte in der konvertierten interaktiven Heatmap erhalten bleiben.

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
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

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