使用R将悬停文本添加到plolty中的方框图中
我已经尝试了一些示例,但无法修复悬停文本 下面是一个简单的例子:使用R将悬停文本添加到plolty中的方框图中,r,ggplot2,plotly,ggplotly,R,Ggplot2,Plotly,Ggplotly,我已经尝试了一些示例,但无法修复悬停文本 下面是一个简单的例子: library(ggplot2) library(plotly) newhovertext=paste0(iris$Species,"<br>",iris$Sepal.Width) g <- ggplot(iris,aes(x=Species,y=Sepal.Width,label=newhovertext)) + geom_boxplot(alpha=0.5) plotly::ggplotly(g,
library(ggplot2)
library(plotly)
newhovertext=paste0(iris$Species,"<br>",iris$Sepal.Width)
g <- ggplot(iris,aes(x=Species,y=Sepal.Width,label=newhovertext)) +
geom_boxplot(alpha=0.5)
plotly::ggplotly(g,tooltip=label)
库(ggplot2)
图书馆(绘本)
newhovertext=paste0(鸢尾$Species,“
”,鸢尾$Sepal.Width)
g您可以执行以下操作:
library(ggplot2)
library(plotly)
library(datasets)
data(iris)
newhovertext=paste0(iris$Species,"<br>",iris$Sepal.Width)
g<-ggplot(iris,aes(x=Species,y=Sepal.Width, label=newhovertext))+
geom_boxplot(alpha=0.5)
g %>% ggplotly()
您可以在中看到结果绘图:不适用于plotly 4.9.1。这是一个我正在运行的简单报告,不需要闪亮。一个你上传的图像截图@大卫,请看另一个链接
gg_box <- iris %>%
ggplot(aes(x=Species, y=Sepal.Width, text=paste("Species:",Species, "\n",
"Width:", Sepal.Width))) +
geom_boxplot()+
#invisible layer of points
geom_point(alpha = 0)
gg_box %>%
ggplotly()