将工具提示与plotly_build()结合使用以防止悬停文本两次显示

时间:2019-12-18 03:46:56

标签: r ggplot2 plotly

我的数据框如下:

Firebase: Firebase App named '[DEFAULT]' already exists

并且我设法使用etf_id<-c("a","b","c","d","e","a","b","c","d","e","a","b","c","d","e") factor<-c("A","A","A","A","A","B","B","B","B","B","C","C","C","C","C") normalized<-c(-0.048436801,2.850578601,2.551666490,0.928625186,-0.638111793, -0.540615895,-0.501691539,-1.099239823,-0.040736139,-0.192048665, 0.198915407,-0.092525810,0.214317734,2.550478998,0.024613778) df<-data.frame(etf_id,factor,normalized) 方法删除了异常值:

plotly_build()

问题是悬停文本显示两次,而p<-df %>% ggplot(aes(factor, normalized, color = factor)) + geom_boxplot(outlier.color = NA,outlier.size = 0,outlier.shape = NA) + coord_cartesian(ylim = quantile(df$normalized, c(0.01, 0.99), na.rm = T)) + geom_point(data = df, aes(x = factor, y = normalized, shape = etf_id, color = etf_id, text = paste("ticker: ", etf_id, "<br> factor: ", factor, "<br> normalized: ", round(normalized, 4), sep = "")), size = 2) # Need to modify the plotly object and make outlier points have opacity equal to 0 p <- plotly_build(p) for(i in 1:length(p$x$data)) { p$x$data[[i]]$marker$opacity = 0 } p 不接受plotly_build()参数来解决它。

over text from displaying twice.

0 个答案:

没有答案