[R-plotly] Hovertemplate fails in violin plot
未关闭
还没有人认领这个 Issue。
- 主要语言
- R
- 星标
- 2.7k
- 派生
- 641
- PR 合并指标
- 30 天内没有已合并 PR
描述
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
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
复现提供的 R 小提琴图示例,并将其悬停行为与正常工作的散点图案例以及相关的箱线图 issue #1636 进行比较。从 R 示例追踪小提琴图的悬停处理,到相关的 plotly.R 入口点;当 hovertemplate 和 hoverinfo 显示所请求的 y 文本,同时不丢失 KDE 悬停信息时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- r
- 领域
- data-visualization
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 38/100