Debian Codegraph @

man/scale_colour_continuous_sequential.Rd

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