% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/UserFacingCoreFunctions.R
\name{scale_continuous_plus}
\alias{scale_continuous_plus}
\title{Continuous Scales With Endpoint-Aware Breaks}
\usage{
scale_continuous_plus(
  scale = NA,
  ...,
  thin.labels = FALSE,
  pad.labels = "start",
  target.breaks = 5,
  buffer_frac = 0.05,
  split_name = FALSE
)
}
\arguments{
\item{scale}{Character string specifying which scale to modify. Options are
\code{"x"}, \code{"y"}, \code{"colour"}/\code{"color"}, and \code{"fill"}.}

\item{...}{Additional arguments passed to the corresponding ggplot2
continuous scale function. Arguments such as \code{name}, \code{labels}, \code{guide},
\code{position}, and \code{expand} may be supplied. User-supplied \code{breaks}, \code{limits},
\code{n.breaks}, \code{trans}, and \code{transform} are ignored with a warning because
this function controls those components directly.}

\item{thin.labels}{Logical. If \code{TRUE}, every other break label is blanked
to reduce crowding. Defaults to \code{FALSE}.}

\item{pad.labels}{Character string, either \code{"start"} or \code{"end"}. Used when a
user-supplied label vector is shorter than the internally computed break
vector by one label (which must be assessed via trial and error currently). \code{"start"} pads a blank label at the beginning;
\code{"end"} pads one at the end.}

\item{target.breaks}{Integer target number of major breaks. This is a target and
not a guarantee because breaks are chosen using a "pretty" break algorithm.
Default is \code{5}.}

\item{buffer_frac}{Numeric fraction of the data span used to decide whether a
break is close enough to each endpoint. Default is \code{0.05}.}

\item{split_name}{Logical. If \code{TRUE}, spaces in a named \code{name} argument are
replaced with line breaks. This can help long axis or legend titles fit
better. Default is \code{FALSE}.}
}
\value{
A ggplot2 continuous scale object.
}
\description{
\code{scale_continuous_plus()} is an opinionated wrapper around ggplot2's
continuous x, y, colour, and fill scales. It chooses "pretty" breaks while
gently expanding the scale limits so breaks generally will appear near both
ends of the data range.
}
\details{
This is useful because ggplot2's default continuous scales frequently will leave the ends of an
axis or colorbar visually unlabeled, making it look as if an endpoint break is
missing.

\code{scale_continuous_plus()} routes to one of
\code{\link[ggplot2:scale_continuous]{ggplot2::scale_x_continuous()}}, \code{\link[ggplot2:scale_continuous]{ggplot2::scale_y_continuous()}},
\code{\link[ggplot2:scale_colour_continuous]{ggplot2::scale_colour_continuous()}}, or
\code{\link[ggplot2:scale_colour_continuous]{ggplot2::scale_fill_continuous()}} based on \code{scale}.

Unlike the ggplot2 defaults, this function intentionally controls \code{breaks}
and \code{limits}. If either is supplied through \code{...}, it's ignored with a
warning. Transformed scales are also not currently supported; pre-transform
the data or use ggplot2's scale functions directly when a transformed scale is
needed.

User-supplied label vectors are supported, but endpoint-aware breaks can
sometimes create hidden outer breaks. When possible, this function pads label
vectors with blank labels to align them with the computed break vector in length. If
alignment is ambiguous by one label, use \code{pad.labels} to choose which side of the input labels vector to
pad.
}
\examples{
library(ggplot2)

ggplot(iris, aes(Sepal.Width, Sepal.Length)) +
  geom_point() +
  scale_continuous_plus(scale = "x") +
  scale_continuous_plus(scale = "y")

ggplot(iris, aes(Sepal.Width, Sepal.Length, fill = Petal.Length)) +
  geom_point(shape = 21) +
  scale_continuous_plus(scale = "x") +
  scale_continuous_plus(scale = "y") +
  scale_continuous_plus(scale = "fill")

ggplot(iris, aes(Sepal.Width, Sepal.Length)) +
  geom_point() +
  scale_continuous_plus(
    scale = "y",
    name = "Sepal length",
    labels = LETTERS[1:5],
    pad.labels = "start"
  )

}
