Switches the axis position of the x or y axis in a ggplot2 plot.

p <- ggplot(mtcars, aes(mpg, disp)) + geom_line(colour = "blue")
ggdraw(switch_axis_position(p, axis = 'y'))

plot of chunk switch_axis_position

ggdraw(switch_axis_position(p, axis = 'x'))

plot of chunk switch_axis_position

ggdraw(switch_axis_position(p + theme_bw(), axis = 'xy', keep = 'x'))

plot of chunk switch_axis_position