Add check marks without labels at the top of the strip in ggplot2
1 answer
I adapted Baptiste's solution from the link Show y-axis for each subheading while cutting . The idea (I think) is to extract the x-axis of the grob and add it to the top of the graph.
library(ggplot2)
library(gtable)
# plot
p1 <- ggplot(mtcars, aes(factor(cyl))) + geom_bar() + theme_bw()
gg <- ggplotGrob(p1)
axis <- gtable_filter(gg ,"axis-b")[["grobs"]][[1]][["children"]][["axis"]][1,]
panels <- subset(gg$layout, name == "panel")
gg <- gtable_add_grob(gg, grobs=axis, name="ticks", t = panels$t-1, l=panels$l)
grid.newpage()
grid.draw(gg)
+1
source to share