Debian Codegraph @

man/demoplot.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/demoplot.R
3 \name{demoplot}
4 \alias{demoplot}
5 \title{Color Palette Demonstration Plot}
6 \usage{
7 demoplot(
8 x,
9 type = c("map", "heatmap", "scatter", "spine", "bar", "pie", "perspective", "mosaic",
10 "lines"),
11 ...
12 )
13 }
14 \arguments{
15 \item{x}{character vector containing color hex codes.}
16
17 \item{type}{character indicating the type of demonstration plot.}
18
19 \item{\dots}{currently not used.}
20 }
21 \value{
22 \code{demoplot} returns invisibly what the respective base graphics
23 functions return that are called internally.
24 }
25 \description{
26 Demonstration of color palettes in various kinds of statistical graphics.
27 }
28 \details{
29 To demonstrate how different kinds of color palettes work in different
30 kinds of statistical displays, \code{demoplot} provides a simple convenience
31 interface to some base graphics with (mostly artificial) data sets.
32 All types of demos can deal with arbitrarily many colors. However, some
33 displays are much more suitable for a low number of colors (e.g., the pie
34 chart) while others work better with more colors (e.g., the heatmap).
35 }
36 \examples{
37 ## all built-in demos with the same sequential heat color palette
38 par(mfrow = c(3, 3))
39 cl <- sequential_hcl(5, "Heat")
40 for (i in c("map", "heatmap", "scatter", "spine", "bar", "pie", "perspective", "mosaic", "lines")) {
41 demoplot(cl, type = i)
42 }
43
44 ## qualitative palettes: light pastel colors for shading areas (pie)
45 ## and darker colorful palettes for points or lines
46 demoplot(qualitative_hcl(4, "Pastel 1"), type = "pie")
47 demoplot(qualitative_hcl(4, "Set 2"), type = "scatter")
48 demoplot(qualitative_hcl(4, "Dark 3"), type = "lines")
49
50 ## sequential palettes: display almost continuous gradients with
51 ## strong luminance contrasts (heatmap, perspective) and colorful
52 ## sequential palette for spine plot with only a few ordered categories
53 demoplot(sequential_hcl(99, "Purple-Blue"), type = "heatmap")
54 demoplot(sequential_hcl(99, "Reds"), type = "perspective")
55 demoplot(sequential_hcl(4, "Viridis"), type = "spine")
56
57 ## diverging palettes: display almost continuous gradient with
58 ## strong luminance contrast bringing out the extremes (map),
59 ## more colorful palette with lower luminance contrasts for displays
60 ## with fewer colors (mosaic, bar)
61 demoplot(diverging_hcl(99, "Tropic", power = 2.5), type = "map")
62 demoplot(diverging_hcl(5, "Green-Orange"), type = "mosaic")
63 demoplot(diverging_hcl(5, "Blue-Red 2"), type = "bar")
64
65 ## some palettes that work well on black backgrounds
66 par(mfrow = c(2, 3), bg = "black")
67 demoplot(sequential_hcl(9, "Oslo"), "heatmap")
68 demoplot(sequential_hcl(9, "Turku"), "heatmap")
69 demoplot(sequential_hcl(9, "Inferno", rev = TRUE), "heatmap")
70 demoplot(qualitative_hcl(9, "Set 2"), "lines")
71 demoplot(diverging_hcl(9, "Berlin"), "scatter")
72 demoplot(diverging_hcl(9, "Cyan-Magenta", l2 = 20), "lines")
73
74 }
75 \references{
76 Zeileis A, Fisher JC, Hornik K, Ihaka R, McWhite CD, Murrell P, Stauffer R, Wilke CO (2020).
77 \dQuote{colorspace: A Toolbox for Manipulating and Assessing Colors and Palettes.}
78 \emph{Journal of Statistical Software}, \bold{96}(1), 1--49. \doi{10.18637/jss.v096.i01}
79 }
80 \seealso{
81 \code{\link{specplot}}, \code{\link{hclplot}}
82 }
83 \keyword{hplot}