issue: position_dodge alters hover values
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- R
- Sterne
- 2.7k
- Forks
- 641
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
Problem: using position_dodge in at least geom_point seems to incorrectly assign the group values shown when hovering on a point. This is related to whether or not the values in the plot x-axis factor are alphabetically ordered.
Example:
library(ggplot2)
library(plotly)
#Data with x-axis factor in alphabetical order (a, b, c):
data <- data.frame('Col1' = c('a', 'b', 'c'), 'Col2'= factor(1:3), Col3 = c('A1', 'A2', 'A3'), 'Val' = c(10,5,1))
#Hovering on plot dots gives correct values, regardless of position_dodge.
ggplotly(ggplot(data, aes(x = Col1, y = Val, group = Col2:Col3)) + geom_point())
ggplotly(ggplot(data, aes(x = Col1, y = Val, group = Col2:Col3)) + geom_point(position = position_dodge(0.6)))
#Data with x-axis factor in non alphabetical order (c, a, b):
data1 <- data.frame('Col1' = c('c', 'a', 'b'), 'Col2'= factor(1:3), Col3 = c('A1', 'A2', 'A3'), 'Val' = c(10,5,1))
#Hovering on plot dots gives correct values if no position_dodge is used:
ggplotly(ggplot(data1, aes(x = Col1, y = Val, group = Col2:Col3)) + geom_point())
#Hovering on plot dots gives incorrect values (as if the x-axis levels had been reordered?) if position_dodge is used:
ggplotly(ggplot(data1, aes(x = Col1, y = Val, group = Col2:Col3)) + geom_point(position = position_dodge(0.6)))
Both solution and temporary workaround are appreciated. Plotly is superb, thank you so much for putting your time on it.
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, die beiden ggplotly-Beispiele mit geom_point und position_dodge auszuführen, und vergleiche die alphabetischen und nicht alphabetischen Fälle von Col1. Verfolge, wie ggplotly gruppierte Punktdaten in Hover-Werte überträgt; als abgeschlossen gilt die Aufgabe, wenn die angezeigten Gruppenwerte bei Verwendung von position_dodge weiterhin den richtigen Punkten zugeordnet 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
- 35/100