This function provides a simple way to set the background grid in ggplot2. It
doesn't do anything that can't be done just the same with theme()
. However, it simplifies
creation of the most commonly needed variations.
Specifies along which axes you would like to plot major grid lines. Options are "xy", "x", "y", "none".
Specifies along which axes you would like to plot minor grid lines. Options are "xy", "x", "y", "none".
Size of the major grid lines.
Size of the minor grid lines.
Color of the major grid lines.
Color of the minor grid lines.
Note: This function completely overwrites all background grid settings of the current theme. If that
is not what you want, you may be better off using theme()
directly.
library(ggplot2)
ggplot(iris, aes(Sepal.Length, Sepal.Width)) +
geom_point() +
theme_half_open() +
background_grid()