由网友(烟雨梦兮)分享简介:有没有办法在 ggplotly 对象中自定义 hoverinfo?Is there a way to customize hoverinfo in a ggplotly object? 例如,p <- ggplot(mtcars, aes(x = disp, y= am, color = as.factor(cy...
有没有办法在 ggplotly 对象中自定义 hoverinfo?
Is there a way to customize hoverinfo in a ggplotly object?
例如,
p <- ggplot(mtcars, aes(x = disp, y= am, color = as.factor(cyl)))+geom_point()
ggplotly(p)
这里的悬停信息框包含三个变量:disp、am和factor(cyl).如何在悬停信息框中包含更多变量或排除现有变量?
The hover information box here contains three variables:disp,am and factor(cyl). How to include more variables or exclude existing variables in the hover information box?
谢谢!
推荐答案
您可以在 aes()
中包含所需的变量,然后使用 tooltip
指定应显示的变量:
You can include required variables in aes()
then use tooltip
to specify which should be displayed:
p <- ggplot(mtcars, aes(x = disp, y= am, color = as.factor(cyl),
gear=gear, hp=hp))+geom_point()
ggplotly(p,tooltip = c("x", "gear", "hp"))
相关推荐
最新文章