ggplotly only displays one legend
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- R
- Sterne
- 2.7k
- Forks
- 641
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
While ggplot produces legends for each aesthetic (other than x & y), after calling ggplotly on the result, only one legend remains (although both titles display).
library(tidyverse)
library(gapminder)
library(plotly)
p <- gapminder %>%
filter(year == 2007) %>%
mutate(pop_m = pop / 1000000) %>%
ggplot(aes(x = gdpPercap, y = lifeExp, colour = continent, size = pop_m, text = country)) +
geom_point() +
scale_x_log10(label = scales::comma) +
scale_size_continuous(label = scales::comma, breaks = c(0, 1, 10, 100, 1000), range = c(1, 10)) +
labs(x = "GDP per capita ($)", y = "Life expectancy (years)", size = "Population, millions", colour = "Continent")
p
ggplotly(p, tooltip = "text")


I don't think this "disappearing legend" problem is a duplicate amongst the issues I've reviewed, but there is some discussion of this on StackOverflow.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne damit, das reproduzierbare R-Beispiel im Issue auszuführen, und vergleiche die ggplot- und ggplotly-Ausgaben einschließlich der Farb- und Größenelegenden. Verfolge den für die Legenden verantwortlichen ggplotly-Konvertierungspfad; abgeschlossen ist die Aufgabe, wenn beide Legenden nach der Konvertierung mit ihren Titeln und Skalen sichtbar bleiben.
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
- 45/100