答案 0 :(得分:2)
你在找这样的东西吗?
您只需要发送ggplot
来电,然后在tooltip
论证中提问。
draw_a_boxplot <- function(data,y,color){
data$quality <- as.factor(data$quality)
p <- ggplot(data,aes(data[,I(color)],data[,y], text = paste("TextYouWant1:", data[,I(color)], "<br>", "TextYouWant2:", data[,y]), "<br>", "TextYouWant3:", data[,color]))+
geom_boxplot(aes(colour=data[,color]))+
geom_jitter(width = 0.2,aes(colour=data[,color]))+
xlab(color) +
ylab(y) +
ggtitle(paste0("BoxPlot-Jitter-",color,"-",y))
return(ggplotly(p,tooltip = c("text")))
}
draw_a_boxplot(wines,"volatile.acidity","quality")