% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/UserFacingCoreFunctions.R
\name{gridlines_plus}
\alias{gridlines_plus}
\title{Subtle, Minimal Gridlines For When and Where They Help}
\usage{
gridlines_plus(
  color = "gray90",
  linewidth = 1.2,
  linetype = "solid",
  notx = FALSE,
  noty = FALSE,
  override_legend_alphasize = TRUE,
  enable_coaching = TRUE
)
}
\arguments{
\item{color}{Gridline color. Single character string. Default: \code{"gray90"}.}

\item{linewidth}{Gridline width (theme line units). Single numeric. Default: \code{1.2}.}

\item{linetype}{Gridline type. Single string (e.g., \code{"solid"}, \code{"dashed"}).}

\item{notx, noty}{Logicals indicating whether gridlines should not be drawn in a specific direction (i.e., the user wants those to be blank even when the axis is continuous). Default to FALSE (gridlines are added).}

\item{override_legend_alphasize}{Logical indicating whether, for any fill, color, and/or shape legends, to override the size and/or alpha values to the ggplotplus default values (1 and 5, respectively). Defaults to TRUE.}

\item{enable_coaching}{Logical indicating whether ggplotplus should perform certain automated checks for possible non-Universal graph design and provide coaching messages when these are detected. Defaults to TRUE.}
}
\value{
An ggplot class object for adding to a plot with \code{+}.
}
\description{
Adds light and easily ignored major gridlines along only axes mapped to
continuous variables. Minor gridlines are
blanked. This enables the benefits of gridlines (in instances where there are some) but minimizes visual clutter and cognitive load.
}
\details{
\code{gridlines_plus()} ignores any theme instructions to blank major panel scales in either the x or y direction via, e.g., \code{theme_plus(panel.grid.major.y = ggplot2::element_blank())}. Instead, users can set, e.g., noty == TRUE to prevent gridlines from being drawn in a specific direction, even if that scale is continuous. Similarly, gridline color, linewidth, and linetypes should be set directly in \code{gridlines_plus()} instead of via \code{theme()}. Trying to do the latter will fail without error or warning!

Under the hood, \code{gridlines_plus()} checks layer and/or global mappings to
see if \code{x} and/or \code{y} are continuous. It does this by inspecting the trained panel scales.
It then turns on \strong{major} gridlines for continuous directions and explicitly
blanks gridlines for other axes (as well as \strong{all minor} gridlines).
}
\examples{
library(ggplot2)

ggplot2::ggplot(iris, ggplot2::aes(Sepal.Length, Petal.Length)) +
  ggplot2::geom_point() +
  theme_plus() + #WE DON'T RECOMMEND USING gridlines_plus() WITHOUT ALSO USING theme_plus()
  gridlines_plus()

# Only y is continuous here (x is discrete) → y-only major gridlines
ggplot2::ggplot(mtcars, ggplot2::aes(factor(cyl), mpg)) +
  ggplot2::geom_boxplot() +
  gridlines_plus(color = "grey85", linewidth = 1, linetype = "dashed")

# Works with derived continuous axes (histogram)
ggplot2::ggplot(mtcars, aes(mpg)) +
  ggplot2::geom_histogram() +
  gridlines_plus()

}
