Learn R Programming

ggthemr (version 1.1.0)

random_swatch_colour: Random swatch colour

Description

Gives a random colour from ggthemr swatch. This might be useful if you are producing lots of plots with one colour, which can get a bit boring to look at. You can use this function to get a random colour for each of your plots to make them more interesting.

Usage

random_swatch_colour(limit = 4L)

Arguments

limit

How many colours from the swatch should be considered for sampling (see details).

Details

The first colour of the swatch will never be returned as this is a special value. The first few colours are usually "better" as they are well suited to the theme and have good contrast with each other. The random colour is therefore limited by default to the first few colours.

Examples

Run this code
# NOT RUN {
ggthemr('dust')
ggplot(diamonds, aes(carat, price)) + 
  geom_point(colour = random_swatch_colour())

colorem <- random_swatch_colour()
ggplot(diamonds, aes(color, price)) + 
  geom_boxplot(fill = colorem, outlier.colour = colorem)
# }

Run the code above in your browser using DataLab