plotly + ggplot2: Some tooltips missing in stacked barplot

前端 未结 1 1289
盖世英雄少女心
盖世英雄少女心 2021-01-22 06:37

Given for example

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\         


        
相关标签:
1条回答
  • 2021-01-22 07:16

    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
    

    0 讨论(0)
提交回复
热议问题