且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

plotly + ggplot2:堆叠条形图中缺少一些工具提示

更新时间:2023-11-26 11:59:10

adding some code. We can fix it:

library(ggplot2)
library(plotly)
df <- data.frame(V1=gl(6,20), V2=gl(40,3))
p <- ggplot(df, aes(x=V1, fill=V2)) + geom_bar(color="white")
fixed<-ggplotly(p)

for (i in 1:length(levels(df$V2))){
  fixed$x$data[[i]]$text[length(fixed$x$data[[i]]$text)+1] <- c("")
}
fixed