| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/scale_sequential.R |
| 3 |
\name{scale_colour_discrete_sequential} |
| 4 |
\alias{scale_colour_discrete_sequential} |
| 5 |
\alias{scale_color_discrete_sequential} |
| 6 |
\alias{scale_fill_discrete_sequential} |
| 7 |
\title{HCL-Based Discrete Sequential Color Scales for ggplot2} |
| 8 |
\usage{ |
| 9 |
scale_colour_discrete_sequential( |
| 10 |
palette = NULL, |
| 11 |
c1 = NULL, |
| 12 |
c2 = NULL, |
| 13 |
cmax = NULL, |
| 14 |
l1 = NULL, |
| 15 |
l2 = NULL, |
| 16 |
h1 = NULL, |
| 17 |
h2 = NULL, |
| 18 |
p1 = NULL, |
| 19 |
p2 = NULL, |
| 20 |
alpha = 1, |
| 21 |
rev = TRUE, |
| 22 |
nmax = NULL, |
| 23 |
order = NULL, |
| 24 |
aesthetics = "colour", |
| 25 |
... |
| 26 |
) |
| 27 |
|
| 28 |
scale_color_discrete_sequential( |
| 29 |
palette = NULL, |
| 30 |
c1 = NULL, |
| 31 |
c2 = NULL, |
| 32 |
cmax = NULL, |
| 33 |
l1 = NULL, |
| 34 |
l2 = NULL, |
| 35 |
h1 = NULL, |
| 36 |
h2 = NULL, |
| 37 |
p1 = NULL, |
| 38 |
p2 = NULL, |
| 39 |
alpha = 1, |
| 40 |
rev = TRUE, |
| 41 |
nmax = NULL, |
| 42 |
order = NULL, |
| 43 |
aesthetics = "colour", |
| 44 |
... |
| 45 |
) |
| 46 |
|
| 47 |
scale_fill_discrete_sequential(..., aesthetics = "fill") |
| 48 |
} |
| 49 |
\arguments{ |
| 50 |
\item{palette}{The name of the palette to be used. Run \code{hcl_palettes(type = "sequential")} for available options.} |
| 51 |
|
| 52 |
\item{c1}{Beginning chroma value.} |
| 53 |
|
| 54 |
\item{c2}{Ending chroma value.} |
| 55 |
|
| 56 |
\item{cmax}{Maximum chroma value.} |
| 57 |
|
| 58 |
\item{l1}{Beginning luminance value.} |
| 59 |
|
| 60 |
\item{l2}{Ending luminance value.} |
| 61 |
|
| 62 |
\item{h1}{Beginning hue value.} |
| 63 |
|
| 64 |
\item{h2}{Ending hue value. If set to \code{NA}, generates a single-hue scale.} |
| 65 |
|
| 66 |
\item{p1}{Control parameter determining how chroma should vary (1 = linear, 2 = quadratic, etc.).} |
| 67 |
|
| 68 |
\item{p2}{Control parameter determining how luminance should vary (1 = linear, 2 = quadratic, etc.).} |
| 69 |
|
| 70 |
\item{alpha}{Numeric vector of values in the range \code{[0, 1]} for alpha transparency channel (0 means transparent and 1 means opaque).} |
| 71 |
|
| 72 |
\item{rev}{If \code{TRUE} (default), reverses the order of the colors in the color scale (compared to \code{\link{sequential_hcl}}).} |
| 73 |
|
| 74 |
\item{nmax}{Maximum number of different colors the palette should contain. If not provided, is calculated automatically |
| 75 |
from the data.} |
| 76 |
|
| 77 |
\item{order}{Numeric vector listing the order in which the colors should be used. Default is \code{1:nmax}.} |
| 78 |
|
| 79 |
\item{aesthetics}{The ggplot2 aesthetics to which this scale should be applied.} |
| 80 |
|
| 81 |
\item{...}{common discrete scale parameters: \code{name}, \code{breaks}, \code{labels}, \code{na.value}, \code{limits} and \code{guide}. See |
| 82 |
\code{\link[ggplot2]{discrete_scale}} for more details.} |
| 83 |
} |
| 84 |
\description{ |
| 85 |
Discrete ggplot2 color scales using the color palettes generated by \code{\link{sequential_hcl}}. |
| 86 |
} |
| 87 |
\details{ |
| 88 |
If both a valid palette name and palette parameters are provided then the provided palette parameters overwrite the parameters in the |
| 89 |
named palette. This enables easy customization of named palettes. |
| 90 |
|
| 91 |
Compared to \code{\link{sequential_hcl}} the ordering of the colors in the sequential ggplot2 scale |
| 92 |
are reversed by default (i.e., \code{rev = TRUE}) to be more consistent with ggplot2's own scales such as |
| 93 |
\code{\link[ggplot2]{scale_color_brewer}}. For most named palettes this leads to darker and more |
| 94 |
colorful colors for larger values on the scale. This is typically the better default on light/white |
| 95 |
backgrounds. |
| 96 |
} |
| 97 |
\examples{ |
| 98 |
library("ggplot2") |
| 99 |
|
| 100 |
# default colors |
| 101 |
ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Species)) + |
| 102 |
geom_point() + scale_color_discrete_sequential() + theme_classic() |
| 103 |
|
| 104 |
# customization of named palette |
| 105 |
ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Species)) + |
| 106 |
geom_point() + scale_colour_discrete_sequential(palette = "Reds", nmax = 4, p2 = 1.5) + |
| 107 |
theme_classic() |
| 108 |
|
| 109 |
# color scale "Terrain" |
| 110 |
ggplot(iris, aes(Sepal.Length, fill = Species)) + |
| 111 |
geom_density(alpha = 0.7) + scale_fill_discrete_sequential(palette = "Terrain") + theme_minimal() |
| 112 |
} |