% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/geom_stripped_rows.R
\name{geom_stripped_rows}
\alias{geom_stripped_rows}
\alias{geom_stripped_cols}
\title{Alternating Background Colour}
\usage{
geom_stripped_rows(
  mapping = NULL,
  data = NULL,
  stat = "identity",
  position = "identity",
  ...,
  show.legend = NA,
  inherit.aes = TRUE,
  xfrom = -Inf,
  xto = Inf,
  width = 1,
  nudge_y = 0
)

geom_stripped_cols(
  mapping = NULL,
  data = NULL,
  stat = "identity",
  position = "identity",
  ...,
  show.legend = NA,
  inherit.aes = TRUE,
  yfrom = -Inf,
  yto = Inf,
  width = 1,
  nudge_x = 0
)
}
\arguments{
\item{mapping}{Set of aesthetic mappings created by \code{\link[ggplot2:aes]{aes()}} or
\code{\link[ggplot2:aes_]{aes_()}}. If specified and \code{inherit.aes = TRUE} (the
default), it is combined with the default mapping at the top level of the
plot. You must supply \code{mapping} if there is no plot mapping.}

\item{data}{The data to be displayed in this layer. There are three
options:

If \code{NULL}, the default, the data is inherited from the plot
data as specified in the call to \code{\link[ggplot2:ggplot]{ggplot()}}.

A \code{data.frame}, or other object, will override the plot
data. All objects will be fortified to produce a data frame. See
\code{\link[ggplot2:fortify]{fortify()}} for which variables will be created.

A \code{function} will be called with a single argument,
the plot data. The return value must be a \code{data.frame}, and
will be used as the layer data. A \code{function} can be created
from a \code{formula} (e.g. \code{~ head(.x, 10)}).}

\item{stat}{The statistical transformation to use on the data for this
layer, as a string.}

\item{position}{Position adjustment, either as a string, or the result of
a call to a position adjustment function.}

\item{...}{Other arguments passed on to \code{\link[ggplot2:layer]{layer()}}. These are
often aesthetics, used to set an aesthetic to a fixed value, like
\code{colour = "red"} or \code{size = 3}. They may also be parameters
to the paired geom/stat.}

\item{show.legend}{logical. Should this layer be included in the legends?
\code{NA}, the default, includes if any aesthetics are mapped.
\code{FALSE} never includes, and \code{TRUE} always includes.
It can also be a named logical vector to finely select the aesthetics to
display.}

\item{inherit.aes}{If \code{FALSE}, overrides the default aesthetics,
rather than combining with them. This is most useful for helper functions
that define both data and aesthetics and shouldn't inherit behaviour from
the default plot specification, e.g. \code{\link[ggplot2:borders]{borders()}}.}

\item{xfrom, xto}{limitation of the strips along the x-axis}

\item{width}{width of the strips}

\item{yfrom, yto}{limitation of the strips along the y-axis}

\item{nudge_x, nudge_y}{horizontal or vertical adjustment to nudge strips by}
}
\description{
Add alternating background color along the y-axis. The geom takes default
aesthetics \code{odd} and \code{even} that receive color codes.
}
\examples{
# Small function to display plots only if it's interactive
p_ <- GGally::print_if_interactive

data(tips, package = "reshape")
p <- ggplot(tips) +
  aes(x = time, y = day) +
  geom_count() +
  theme_light()

p_(p)
p_(p + geom_stripped_rows())
p_(p + geom_stripped_cols())
p_(p + geom_stripped_rows() + geom_stripped_cols())

p <- ggplot(tips) +
  aes(x = total_bill, y = day) +
  geom_count() +
  theme_light()
p
p_(p + geom_stripped_rows())
p_(p + geom_stripped_rows() + scale_y_discrete(expand = expansion(0, 0.5)))
p_(p + geom_stripped_rows(xfrom = 10, xto = 35))
p_(p + geom_stripped_rows(odd = "blue", even = "yellow"))
p_(p + geom_stripped_rows(odd = "blue", even = "yellow", alpha = .1))
p_(p + geom_stripped_rows(odd = "#00FF0022", even = "#FF000022"))

p_(p + geom_stripped_cols())
p_(p + geom_stripped_cols(width = 10))
p_(p + geom_stripped_cols(width = 10, nudge_x = 5))
}
