% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/bayesplot-colors.R
\name{bayesplot-colors}
\alias{bayesplot-colors}
\alias{color_scheme_set}
\alias{color_scheme_get}
\alias{color_scheme_view}
\title{Set, get, or view \strong{bayesplot} color schemes}
\usage{
color_scheme_set(scheme = "blue")

color_scheme_get(scheme = NULL, i = NULL)

color_scheme_view(scheme = NULL)
}
\arguments{
\item{scheme}{For \code{color_scheme_set()}, either a string naming one of the
available color schemes or a character vector of \emph{exactly six} colors
specifying a custom scheme.

For \code{color_scheme_get()}, \code{scheme} can be missing (to get the
current color scheme) or a string naming one of the preset schemes.

For \code{color_scheme_view()}, \code{scheme} can be missing (to use the
current color scheme) or a character vector containing a subset of the
available scheme names.

See the \strong{Available color schemes} section below for a list of available
scheme names. The \strong{Custom color schemes} section describes how to specify
a custom scheme.}

\item{i}{For \code{color_scheme_get()}, an optional subset of the integers from \code{1}
(lightest) to \code{6} (darkest) indicating which of the colors in the
scheme to return. If \code{i} is not specified then all six colors in the
scheme are included.}
}
\value{
\code{color_scheme_set()} has the side effect of setting the color scheme
used for plotting. It also returns (\link[base:invisible]{invisibly}) a list of
the hexadecimal color values used in \code{scheme}.

\code{color_scheme_get()} returns a list of the hexadecimal color
values (without changing the current scheme). If the \code{scheme} argument
is not specified the returned values correspond to the current color
scheme. If the optional argument \code{i} is specified then the returned
list only contains \code{length(i)} elements.

\code{color_scheme_view()} returns a ggplot object if only a single scheme is
specified and a gtable object if multiple schemes names are specified.
}
\description{
Set, get, or view color schemes. Choose from a preset scheme or create a
custom scheme. See the \strong{Available color schemes} section below for a list
of available scheme names. The \strong{Custom color schemes} section describes how
to specify a custom scheme.
}
\section{Available color schemes}{
 Currently, the available preset color
schemes are:
\itemize{
\item \code{"blue"}, \code{"brightblue"}
\item \code{"gray"}, \code{"darkgray"}
\item \code{"green"}
\item \code{"pink"}
\item \code{"purple"}
\item \code{"red"}
\item \code{"teal"}
\item \code{"yellow"}
\item \href{https://CRAN.R-project.org/package=viridis}{\code{"viridis"}}, \code{"viridisA"},
\code{"viridisB"}, \code{"viridisC"}, \code{"viridisD"}, \code{"viridisE"}
\item \code{"mix-x-y"}, replacing \code{x} and \code{y} with any two of
the scheme names listed above (e.g. "mix-teal-pink", "mix-blue-red",
etc.). The order of \code{x} and \code{y} matters, i.e., the color schemes
\code{"mix-blue-red"} and \code{"mix-red-blue"} are not identical. There is no
guarantee that every possible mixed scheme will look good with every
possible plot.
\item \code{"brewer-x"}, replacing \code{x} with the name of a palette available from
\code{\link[RColorBrewer:brewer.pal]{RColorBrewer::brewer.pal()}} (e.g., \code{brewer-PuBuGn}).
}

If you have a suggestion for a new color scheme please let us know via the
\strong{bayesplot} \href{https://github.com/stan-dev/bayesplot/issues}{issue tracker}.
}

\section{Custom color schemes}{
 A \strong{bayesplot} color scheme consists of six
colors. To specify a custom color scheme simply pass a character vector
containing either the names of six \link[grDevices:colors]{colors} or six
hexadecimal color values (or a mix of names and hex values). The colors
should be in order from lightest to darkest. See the end of the
\strong{Examples} section for a demonstration.
}

\examples{
color_scheme_set("blue")
color_scheme_view()

color_scheme_get()
color_scheme_get(i = c(3, 5)) # 3rd and 5th colors only

color_scheme_get("brightblue")
color_scheme_view("brightblue")

# compare multiple schemes
color_scheme_view(c("pink", "gray", "teal"))
color_scheme_view(c("viridis", "viridisA", "viridisB", "viridisC"))

color_scheme_set("pink")
x <- example_mcmc_draws()
mcmc_intervals(x)

color_scheme_set("teal")
color_scheme_view()
mcmc_intervals(x)

color_scheme_set("red")
mcmc_areas(x, regex_pars = "beta")

color_scheme_set("purple")
color_scheme_view()
y <- example_y_data()
yrep <- example_yrep_draws()
ppc_stat(y, yrep, stat = "mean") + legend_none()

############################
### Mixing color schemes ###
############################
color_scheme_set("mix-teal-pink")
ppc_stat(y, yrep, stat = "sd") + legend_none()
mcmc_areas(x, regex_pars = "beta")

##########################
### ColorBrewer scheme ###
##########################
color_scheme_set("brewer-Spectral")
color_scheme_view()
mcmc_trace(x, pars = "sigma")

###########################
### Custom color scheme ###
###########################
orange_scheme <- c("#ffebcc", "#ffcc80",
                   "#ffad33", "#e68a00",
                   "#995c00", "#663d00")
color_scheme_set(orange_scheme)
color_scheme_view()
mcmc_areas(x, regex_pars = "alpha")
mcmc_dens_overlay(x)
ppc_stat(y, yrep, stat = "var") + legend_none()

}
\seealso{
\code{\link[=theme_default]{theme_default()}} for the default ggplot theme used by
\strong{bayesplot} and \code{\link[=bayesplot_theme_set]{bayesplot_theme_set()}} to change it.
}
