有没有一种方法可以禁用来自ggplotly()对象映射的hoverinfo弹出文本?

时间:2018-11-08 14:55:27

标签: r ggplot2

我想隐藏来自下面geom_text()图中ggplotly()的映射的黑色弹出式hoverinfo。有没有办法做到这一点?

enter image description here

#data

Name<-c("DCH","DCH","DCH","DGI","DGI","DGI","LDP","LDP","LDP","RH","RH","RH","TC","TC","TC")
Class<-c("Class1","Class2","Overlap","Class1","Class2","Overlap","Class1","Class2","Overlap","Class1","Class2","Overlap","Class1","Class2","Overlap")
count<-c(2077,1642,460,1971,5708,566,2316,810,221,2124,3601,413,2160,1097,377)
FinalDF<-data.frame(Name, Class,count)

#plot
library(plotly)
  # Create the stacked bar plot using ggplot()
  stackedBarPlot<- ggplot(data = FinalDF) +
    geom_col(mapping = aes(x = Name, y = count, fill = Class,reference="DB"), width = rep(0.9,5),
             color = "black", position = position_fill(reverse = T)) +
    geom_text(size = 4, position = position_fill(reverse = T, vjust = 0.50), color = "black", 
              mapping = aes(x = Name, y = count, fill = Class, label = round(count)),Reference="DB") +
    coord_flip() +
    scale_fill_manual(values = c('lemonchiffon', 'palegreen3', 'deepskyblue2'),breaks=c("Class1", "Overlap", "Class2"), labels = c(paste("Unique to","DB"), "Overlap", "Unique to Comparison Dataset "),
                      guide = guide_legend(label.position = 'left', label.hjust = 0, label.vjust = 0.5))


    ggplotly(stackedBarPlot)

0 个答案:

没有答案