These functions extract just the axes from a ggplot. get_y_axis()
pulls
the y-axis, while get_x_axis()
pulls the x-axis.
A ggplot or gtable.
Which side of the plot is the axis on? For the x-axis, this can be "top" or "bottom", and for the y-axis, it can be "left" or "right".
library(ggplot2)
p <- ggplot(mpg, aes(displ, cty)) +
geom_point()
ggdraw(get_y_axis(p))
p <- p + scale_x_continuous(position = "top")
ggdraw(get_x_axis(p, position = "top"))