Custom hover effects for each point in plotly boxplot with markers in R

跟風遠走 提交于 2019-12-24 19:28:20

问题


The following link - https://plot.ly/r/box-plots/#basic-boxplot - leads to the main tutorial that plotly offers for boxplots in R, and the specific plot type that I am interested in working with is the following:

p <- plot_ly(y = ~rnorm(50), type = "box", boxpoints = "all", jitter = 0.3,
        pointpos = -1.8)

In particular, I would like to play around with the hovertext on these plots, so that I am able to hover over each point individually. For anybody familiar with plotly, is this possible with the boxplot type in plotly R, or would I be forced to use the scatter type?

My plot is going to have ~10-12 different boxplots on it, which would make doing this plot with scatter plots quite difficult. In particular, I like how easy it is to add additional boxplots to this plot, and how the colors update automatically when new plots are added.

In particular, here's a rough example (albeit with fewer boxplots) of what I'm trying to make:


回答1:


I believe you want to change the hovermode under the layout option to closest.

p <- plot_ly(y = ~rnorm(50), type = "box", boxpoints = "all", jitter = 0.3,
    pointpos = -1.8) %>% layout(hovermode = "closest")


来源:https://stackoverflow.com/questions/47602651/custom-hover-effects-for-each-point-in-plotly-boxplot-with-markers-in-r

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!