auto_color: Automatically choose color scale for categorical data.

Description Usage Arguments Examples

View source: R/scales.R

Description

Uses color brewer qualitative Set1 (without the yellow) for data with up to 8 levels and the default ggplot2 color scale otherwise.

Usage

1

Arguments

...

common discrete scale parameters: name, breaks, labels, na.value, limits and guide. See discrete_scale for more details

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
d <- diamonds[sample(nrow(diamonds), 5000), ]
p <- ggplot(d, aes(carat, price))

# fewer than 9 levels
p + geom_point(aes(color = cut(price, breaks = 4))) + auto_color()
p + geom_point(aes(color = cut(price, breaks = 8))) + auto_color()

# more than 8 levels
p + geom_point(aes(color = cut(price, breaks = 9))) + auto_color()
p + geom_point(aes(color = cut(price, breaks = 50))) + auto_color(guide = FALSE)

seaaan/gghlab documentation built on May 29, 2019, 4:24 p.m.