i have same problem this user: i'd make facet_grid
plot discrete x-axis, , i'd have x-axis labels written under each facet rather underneath bottom row of facets. instance:
# drop factor levels make plot smaller diamondsub <- subset(diamonds, (cut=="ideal" | cut=="premium") & (color=="e" | color=="i")) # note scales="free_x" has no practical effect here ggplot(diamondsub, aes(x=clarity, y=price)) + geom_blank()+ geom_boxplot() + facet_grid(cut~color, scales="free_x")
however, i'd prefer not use solution post, use facet_wrap
instead of facet_grid
, because prefer way facet_grid
labels strip text 1 variable on top of columns, , other variable on sides of rows.
is there way x-axis labels under each facet, when x-axes same, using facet_grid
?
you can insert copy of axes inside gtable,
library(gtable) g <- ggplotgrob(p) # locate panels panels <- grep("panel", g$layout$name) top <- unique(g$layout$t[panels]) # intersperse copy of bottom axes <- gtable:::rbind_gtable(gtable:::rbind_gtable(g[seq.int(min(top)), ], g[max(top)+1,], "first"), g[seq(min(top)+1, nrow(g)),], "first") grid.newpage() grid.draw(all)
Comments
Post a Comment