plotly / plotly/plotly.R

issue: position_dodge alters hover values

Offen
#986 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

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

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, 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

Neue Issues direkt in Ihr Postfach

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