在R中带有标记的绘图箱图中每个点的自定义悬停效果
以下链接- https://plot.ly/r/box- plots/#basic-boxplot -通向R中的盒图的主要教程,我感兴趣的特定图类型如下:
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)
尤其是,我想在这些情节上使用悬停文本,以便能够分别悬停在每个点上.对于熟悉plotly的人来说,plotly R中的boxplot类型是否可能实现此目的,还是我会被迫使用散点类型?
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?
我的情节将有约10-12种不同的箱形图,这将使散点图制作此情节变得非常困难.特别是,我喜欢在此绘图中添加其他箱形图很容易,以及添加新绘图后颜色如何自动更新.
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:
我相信您想将布局选项下的悬停模式更改为最接近.
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")