plotly / plotly/plotly.R

[R-plotly] Hovertemplate fails in violin plot

Offen
#1,946 1 Kommentar 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

I attempt to use the hovertemplate argument to format the hover text, but it cannot properly display.
However the argument works for type = "scatter". Similar issue was found in #1636 with box plot.

df <- tibble(x = sample(letters[1:3], 100, replace = T), y = rnorm(100))
df %>% plot_ly(
  x = ~x,
  y = ~y,
  split = ~x,
  type = 'violin',
  box = list(
    visible = TRUE
  ),
  hovertemplate = "%{y}", # not work
  hoveron = "kde",
  jitter = 1,
  alpha = 0.5,
  spanmode = "hard"
  )
)

Screen Shot 2021-04-23 at 23 55 03


Using text argument + hoverinfo will let the hover disappear completely

df %>% plot_ly(
  x = ~x,
  y = ~y,
  split = ~x,
  text = ~y, # using text argument
  type = 'violin',
  box = list(
    visible = TRUE
  ),
  hoverinfo = "text", # with hoverinfo
  hoveron = "kde",
  jitter = 1,
  alpha = 0.5,
  spanmode = "hard"
  )
)

image


Using hoverinfo = "y" comes along with kde

df %>% plot_ly(
  x = ~x,
  y = ~y,
  split = ~x,
  type = 'violin',
  box = list(
    visible = TRUE
  ),
  hoverinfo = "y",
  hoveron = "kde",
  jitter = 1,
  alpha = 0.5,
  spanmode = "hard"
  )

image


However, hoverinfo = "x" works properly,

df %>% plot_ly(
  x = ~x,
  y = ~y,
  split = ~x,
  type = 'violin',
  box = list(
    visible = TRUE
  ),
  hoverinfo = "x",
  hoveron = "kde",
  jitter = 1,
  alpha = 0.5,
  spanmode = "hard"
  )

image

R version = 4.0.5, R-plotly version = 4.9.3

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

Reproduziere die bereitgestellten R-Violin-Plot-Beispiele und vergleiche ihr Hover-Verhalten mit dem funktionierenden Scatter-Fall und dem zugehörigen Box-Plot-Issue #1636. Verfolge die Violin-Hover-Behandlung vom R-Beispiel bis zum relevanten plotly.R-Einstiegspunkt; abgeschlossen, wenn hovertemplate und hoverinfo den angeforderten y-Text anzeigen, ohne die Hover-Informationen der KDE zu verlieren.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
r
Bereich
data-visualization
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
38/100

Neue Issues direkt in Ihr Postfach

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