Skip to contents

A simple function to easily adjust the ggplot gridlines. This acts as a wrapper for the theme elements and is a little more user friendly.

Usage

gridlines_major(
  size = 0.5,
  color = "#d6d6d6",
  linetype = "solid",
  lineend = NULL,
  colour = NULL
)

Arguments

size

Numeric value for line size (default: 0.5)

color

Color of the gridlines (default: "#D6D6D6")

linetype

Type of line (default: "solid")

lineend

Line end style (default: NULL)

colour

Alternative spelling for color (default: NULL)

Value

A list with the ggplot theme changes. This can be added to a ggplot object.

Examples

library(ggplot2)
df <- data.frame(x = factor(rep(letters[1:3], each = 10)),
                 y = rnorm(30),
                 color = rep(c("A", "B"), each = 5))
ggplot(df, aes(x = x, y = y, color = color)) +
  geom_point() +
  gridlines_major(size = 4, color = "pink")