scale_rep: Create your own discrete scale

Description Usage Arguments Examples

Description

This allows you to specify you own set of mappings from levels in the data to aesthetic values that will repeat if a insufficient number of levels is provided.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13

Arguments

...

Other arguments passed on to [discrete_scale()] to control name, limits, breaks, labels and so forth.

values

a set of aesthetic values to map data values to. If this is a named vector, then the values will be matched based on the names. If unnamed, values will be matched in order (usually alphabetical) with the limits of the scale. Will repeat if number of labels is less.

Examples

1
2
3
4
5
6
7
library(ggplot2)

dat <- data.frame(x = sample(LETTERS, 200, TRUE))

ggplot(dat, aes(x = x)) +
  geom_bar(aes(fill = x)) +
    scale_fill_rep(values = rainbow(5))

EmilHvitfeldt/ehlib documentation built on Aug. 15, 2021, 12:34 a.m.