r - Text layer work in ggplot but removed with ggplotly -
i have barplot text layer working fine ggplot library want add interactivity ggplotly fails show text layer updated packages problem persist
df = read.table(text = " id year type amount 1 1991 hiit 22 2 1991 inter 144 3 1991 viit 98 4 1992 hiit 20 5 1992 inter 136 6 1992 viit 108 7 1993 hiit 20 8 1993 inter 120 9 1993 viit 124 10 1994 hiit 26 11 1994 inter 118 12 1994 viit 120 13 1995 hiit 23 14 1995 inter 101 15 1995 viit 140 16 1996 hiit 27 17 1996 inter 103 18 1996 viit 162 19 1997 hiit 24 20 1997 inter 96 21 1997 viit 172 22 1998 hiit 24 23 1998 inter 92 24 1998 viit 177 25 1999 hiit 28 26 1999 inter 45 27 1999 viit 220 28 2000 hiit 26 29 2000 inter 36 30 2000 viit 231", header = true, sep = "") df %>% group_by(year) %>% mutate(type = factor(type, levels = c("inter", "viit", "hiit"))) %>% mutate(ratio = amount / sum(amount)) %>% ggplot(aes(x = factor(year), y = ratio, fill = type)) + geom_bar(stat = "identity") + geom_text(aes(label = percent(ratio)), position = position_stack(vjust = 0.5), size = 4) + scale_y_continuous(name="", labels = percent) + coord_flip() + xlab("pourcentage") + ggtitle("répartition des types par année") + theme(plot.title = element_text(hjust = 0.5)) + theme_minimal()-> gg ggplotly(gg)
here ggplot2 , plotly :
plotly (is possible remove plotly toolbar ?)
my graphic on ggplot ok doesn't work ggplotly can solve ? second question, possible remove toolbar on plotly (cause can adjust graphic mouse) ?
thanks help
you do
gp <- ggplotly(gg) (x in 4:6) gp$x$data[[x]]$x <- 1-gp$x$data[[x]]$x gp$x$config$displaymodebar <- false gp
the issue looks bug. maybe want file on github.
Comments
Post a Comment