1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/scale_sequential.R
\name{scale_colour_continuous_sequential}
\alias{scale_colour_continuous_sequential}
\alias{scale_color_continuous_sequential}
\alias{scale_fill_continuous_sequential}
\title{HCL-Based Continuous Sequential Color Scales for ggplot2}
\usage{
scale_colour_continuous_sequential(
palette = NULL,
c1 = NULL,
c2 = NULL,
cmax = NULL,
l1 = NULL,
l2 = NULL,
h1 = NULL,
h2 = NULL,
p1 = NULL,
p2 = NULL,
alpha = 1,
rev = TRUE,
begin = 0,
end = 1,
na.value = "grey50",
guide = "colourbar",
aesthetics = "colour",
n_interp = 11,
...
)
scale_color_continuous_sequential(
palette = NULL,
c1 = NULL,
c2 = NULL,
cmax = NULL,
l1 = NULL,
l2 = NULL,
h1 = NULL,
h2 = NULL,
p1 = NULL,
p2 = NULL,
alpha = 1,
rev = TRUE,
begin = 0,
end = 1,
na.value = "grey50",
guide = "colourbar",
aesthetics = "colour",
n_interp = 11,
...
)
scale_fill_continuous_sequential(..., aesthetics = "fill")
}
\arguments{
\item{palette}{The name of the palette to be used. Run \code{hcl_palettes(type = "sequential")} for available options.}
\item{c1}{Beginning chroma value.}
\item{c2}{Ending chroma value.}
\item{cmax}{Maximum chroma value.}
\item{l1}{Beginning luminance value.}
\item{l2}{Ending luminance value.}
\item{h1}{Beginning hue value.}
\item{h2}{Ending hue value. If set to \code{NA}, generates a single-hue scale.}
\item{p1}{Control parameter determining how chroma should vary (1 = linear, 2 = quadratic, etc.).}
\item{p2}{Control parameter determining how luminance should vary (1 = linear, 2 = quadratic, etc.).}
\item{alpha}{Numeric vector of values in the range \code{[0, 1]} for alpha transparency channel (0 means transparent and 1 means opaque).}
\item{rev}{If \code{TRUE} (default), reverses the order of the colors in the color scale (compared to \code{\link{sequential_hcl}}).}
\item{begin}{Number in the range of \code{[0, 1]} indicating to which point in the color scale the smallest data value should be mapped.}
\item{end}{Number in the range of \code{[0, 1]} indicating to which point in the color scale the largest data value should be mapped.}
\item{na.value}{Color to be used for missing data points.}
\item{guide}{Type of legend. Use \code{"colourbar"} for continuous color bar.}
\item{aesthetics}{The ggplot2 aesthetics to which this scale should be applied.}
\item{n_interp}{Number of discrete colors that should be used to interpolate the continuous color scale. 11 will work fine in most cases.}
\item{...}{common continuous scale parameters: `name`, `breaks`, `labels`, and `limits`. See
\code{\link[ggplot2]{continuous_scale}} for more details.}
}
\description{
Continuous ggplot2 color scales using the color palettes generated by \code{\link{sequential_hcl}}.
}
\details{
If both a valid palette name and palette parameters are provided then the provided palette parameters overwrite the parameters in the
named palette. This enables easy customization of named palettes.
Compared to \code{\link{sequential_hcl}} the ordering of the colors in the sequential ggplot2 scale
are reversed by default (i.e., \code{rev = TRUE}) to be more consistent with ggplot2's own scales such as
\code{\link[ggplot2]{scale_color_brewer}}. For most named palettes this leads to darker and more
colorful colors for larger values on the scale. This is typically the better default on light/white
backgrounds.
}
\examples{
library("ggplot2")
# base plot
gg <- ggplot(iris, aes(x = Species, y = Sepal.Width, color = Sepal.Length)) +
geom_jitter(width = 0.3) + theme_minimal()
# default settings
gg + scale_color_continuous_sequential()
# switch palette and overwrite some default values
gg + scale_color_continuous_sequential(palette = "Reds", l1 = 20, c2 = 70, p1 = 1)
# select a range out of the entire palette
gg + scale_color_continuous_sequential(palette = "Heat", begin = 0.2, end = 0.8)
# volcano plot
df <- data.frame(height = c(volcano), x = c(row(volcano)), y = c(col(volcano)))
ggplot(df, aes(x, y, fill = height)) +
geom_raster() + scale_fill_continuous_sequential(palette = "Terrain", rev = FALSE) +
coord_fixed(expand = FALSE)
}
|