colors: JASP color palettes

Description Usage Arguments Details Value Examples

Description

JASP color palettes

Usage

1
2
3
4
5
6
7
8
9

Arguments

palette

Palette to choose from.

asFunction

Should a function be returned or the raw colors? If a function is returned, it either takes a single integer or a vector in 0, 1 as input.

...

Further arguments for scale_colour_continuous.

Details

For ggplot2s, the convenience functions scale_JASPcolor_\* and scale_JASPfill_\* exist.

Value

Either a character vector of colors or a function.

Examples

 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
library(ggplot2)
library(jaspGraphs)
setGraphOption("palette", "colorblind")

# use colors directly
colors <- JASPcolors("colorblind")
plot(rnorm(6), col = colors, pch = 16, cex = 2)

colors <- JASPcolors("colorblind")
plot(rnorm(10), col = colors, pch = 16, cex = 2)

# use a function if you want an arbitrary number of colros
colFun <- JASPcolors(palette = "colorblind", asFunction = TRUE)
plot(rnorm(10), col = colFun(10), pch = 16, cex = 2)

# use colorscales in ggplot2
e0 <- 1:10
df <- data.frame(x = e0, y = e0, z = e0, g = factor(e0))
g0 <- ggplot(df, aes(x = x, y = y, color = z, fill = z)) + geom_point(size = 5)
g1 <- ggplot(df, aes(x = x, y = y, color = g, fill = g)) + geom_point(size = 5)
g0

g1 + scale_JASPcolor_discrete() + scale_JASPfill_discrete()

# colorblind is not really suited for a continuous color scale
g0 + scale_JASPcolor_continuous() + scale_JASPfill_continuous()

# viridis already looks a lot better!
setGraphOption("palette", "viridis")
g0 + scale_JASPcolor_continuous() + scale_JASPfill_continuous()

# reset the palette to it's default if you changed it globally!
setGraphOption("palette", "colorblind")

vandenman/JASPgraphs documentation built on Dec. 16, 2021, 5:37 p.m.