Description Usage Arguments Value Author(s) Examples
The grattan palette from darkest to lightest given a number of colours.
1 |
n |
The number of variables/factors over which the palette is to paint. |
dark |
Should a dark palette be used? (Only available for n = 2.) |
reverse |
(logical) Option to reverse the palette. |
A vector of HTML colours to be used.
Hugh Parsonage
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)
dat <- data.frame(i = 1:6,
xmin = 1:6,
xmax = 1:6 + 1,
ymin = 0,
ymax = 1,
fill = gpal(6),
stringsAsFactors = FALSE)
ggplot(dat, aes(xmin = xmin, ymin = ymin,
xmax = xmax, ymax = ymax,
fill = fill)) +
geom_rect() +
geom_text(aes(x = (xmin + xmax) / 2,
y = (ymin + ymax) / 2,
label = i)) +
scale_fill_identity()
# Extended palette available up to 9 colours.
dat <- data.frame(i = 1:9,
xmin = 1:9,
xmax = 1:9 + 1,
ymin = 0,
ymax = 1,
fill = gpal(9),
stringsAsFactors = FALSE)
ggplot(dat, aes(xmin = xmin, ymin = ymin,
xmax = xmax, ymax = ymax,
fill = fill)) +
geom_rect() +
geom_text(aes(x = (xmin + xmax) / 2,
y = (ymin + ymax) / 2,
label = i)) +
scale_fill_identity()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.