[R-plotly] Hovertemplate fails in violin plot
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 2.7k
- Forks
- 641
- PR merge metrics
- No merged PRs in 30d
Description
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"
)
)

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"
)
)

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"
)

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"
)

R version = 4.0.5, R-plotly version = 4.9.3
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the supplied R violin-plot examples and compare their hover behavior with the working scatter case and related box-plot issue #1636. Trace the violin hover handling from the R example into the relevant plotly.R entry point; done when hovertemplate and hoverinfo display the requested y text without losing the KDE hover information.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100