plotly / plotly/plotly.R

Ggplotly does not always make a legend correctly for where there are points and lines

Offen
#1,816 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

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

Beschreibung

Ggplotly does not always make a legend correctly for where there are points and lines. Sometimes it only makes the legend key based on either geom_point or geom_line, whichever is the first layer. Below is an example where it doesn't work. It seems to fix it if the data is arranged by the x variable. It'd be good if it worked for however the data was arranged.

library(dplyr)
library(ggplot2)
library(plotly)

#This doesn't work: the legend is based only on the first geom shape
plot_data <- iris %>% 
  as_tibble() %>%  
  janitor::clean_names() 

plot <- ggplot(data = plot_data, aes(petal_width, petal_length, col = species)) +
  geom_point() +
  geom_line()

plotly::ggplotly(plot)

image

plot_data <- iris %>% 
  as_tibble() %>%  
  janitor::clean_names() %>% 
  arrange(petal_width)

plot <- ggplot(data = plot_data, aes(petal_width, petal_length, col = species)) +
  geom_point() +
  geom_line()

plotly::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 R-Beispiel mit plotly::ggplotly zu reproduzieren, und vergleiche die unsortierten iris-Daten mit der nach petal_width angeordneten Version. Das Issue ist abgeschlossen, wenn die Legende unabhängig von der Reihenfolge der Datenzeilen sowohl die Punkt- als auch die Linienebenen korrekt darstellt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
r
Bereich
data-visualization
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 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.