File: scale_colour_continuous_qualitative.Rd

package info (click to toggle)
r-cran-colorspace 2.0-0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 2,732 kB
  • sloc: ansic: 1,200; makefile: 5
file content (100 lines) | stat: -rw-r--r-- 3,365 bytes parent folder | download | duplicates (3)
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
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/scale_qualitative.R
\name{scale_colour_continuous_qualitative}
\alias{scale_colour_continuous_qualitative}
\alias{scale_color_continuous_qualitative}
\alias{scale_fill_continuous_qualitative}
\title{HCL-Based Continuous Qualitative Color Scales for ggplot2}
\usage{
scale_colour_continuous_qualitative(
  palette = NULL,
  c1 = NULL,
  l1 = NULL,
  h1 = NULL,
  h2 = NULL,
  alpha = 1,
  rev = FALSE,
  begin = 0,
  end = 1,
  na.value = "grey50",
  guide = "colourbar",
  aesthetics = "colour",
  n_interp = 11,
  ...
)

scale_color_continuous_qualitative(
  palette = NULL,
  c1 = NULL,
  l1 = NULL,
  h1 = NULL,
  h2 = NULL,
  alpha = 1,
  rev = FALSE,
  begin = 0,
  end = 1,
  na.value = "grey50",
  guide = "colourbar",
  aesthetics = "colour",
  n_interp = 11,
  ...
)

scale_fill_continuous_qualitative(..., aesthetics = "fill")
}
\arguments{
\item{palette}{The name of the palette to be used. Run \code{hcl_palettes(type = "qualitative")} for available options.}

\item{c1}{Chroma value, used for all colors in the scale.}

\item{l1}{Luminance value, used for all colors in the scale.}

\item{h1}{Beginning hue value.}

\item{h2}{Ending hue value.}

\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}, reverses the order of the colors in the color scale.}

\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{qualitative_hcl}}. These scales are provided
for completeness. It is not normally a good idea to color a continuous variable using a qualitative scale.
}
\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.
}
\examples{
library("ggplot2")

# none of these examples are necessarily good ideas
gg <- ggplot(iris, aes(x = Species, y = Sepal.Width, color = Sepal.Length)) + 
  geom_jitter(width = 0.3) + theme_minimal()
  
gg + scale_color_continuous_qualitative(palette = "Warm")
gg + scale_color_continuous_qualitative(palette = "Cold", l1 = 60)
gg + scale_color_continuous_qualitative(palette = "Harmonic", rev = TRUE)

nx = 87
ny = 61
df <- data.frame(height = c(volcano), x = rep(1:nx, ny), y = rep(1:ny, each = nx))
ggplot(df, aes(x, y, fill=height)) + 
  geom_raster() + scale_fill_continuous_qualitative(palette = "Dark 3") +
  coord_fixed(expand = FALSE)
}