Unexpected behavior with geom_rect and ids arg in ggplotly()
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- R
- Sterne
- 2.7k
- Forks
- 641
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
Expected behavior demonstrated by geom_point. See ggplotly(gg1) below.
Unexpected behavior when using geom_rect with the ids arg across frames with changing number of observations. See ggplotly(gg2) and ggplotly(gg3) below.
### Win 10 x64, Rstudio
library(ggplot2) # ggplot2_3.0.0
library(plotly) # plotly_4.7.1
data(gapminder, package = "gapminder")
# filtering out some countries (soframes have differing number of obs)
sub_countries <- unique(gapminder$country)[1:10]
gapminder2 <- gapminder %>%
filter(((year != 1952) | (country %in% sub_countries)) & year < 1970)
# using geom_point (works)
gg1 <- ggplot(gapminder2) +
geom_point(aes(x = gdpPercap, y = lifeExp,
ids = country,
frame = year)) +
scale_x_log10()
ggplotly(gg1) # correct: sub, full, full, full
# using geom_rect (doesn't work with ids arg)
gg2 <- ggplot(gapminder2) +
geom_rect(aes(xmin = gdpPercap, ymin = lifeExp,
xmax = 1.05 * gdpPercap, ymax = 1.05 * lifeExp,
ids = country,
frame = year)) +
scale_x_log10()
ggplotly(gg2) # incorrect: sub, sub, sub, sub
# using geom_rect, subset on 2nd frame (doesn't work with ids arg)
gapminder3 <- gapminder %>%
filter(((year != 1957) | (country %in% sub_countries)) & year < 1970)
gg3 <- ggplot(gapminder3) +
geom_rect(aes(xmin = gdpPercap, ymin = lifeExp,
xmax = 1.05 * gdpPercap, ymax = 1.05 * lifeExp,
ids = country,
frame = year)) +
scale_x_log10()
ggplotly(gg3) # incorrect: full, sub moves, full, full
# frame year 1952 -> 1957 != 1962 -> 1957 != 1967 -> 1957
Cheers,
Nick
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
Führe die bereitgestellte R-Reproduktion mit ggplot2 und plotly aus und vergleiche geom_point und geom_rect über Frames hinweg, deren Anzahl der Beobachtungen sich ändert. Verfolge den ggplotly-Konvertierungspfad für geom_rect, ids und die Frame-Verarbeitung. Erledigt ist die Aufgabe, wenn geom_rect in jedem Frame die korrekten Beobachtungen und ids beibehält und damit dem demonstrierten erwarteten Verhalten entspricht.
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