color_repel {colorrepel} | R Documentation |
Reorder ggplot colors to maximize color differences in space
Description
Reorder ggplot colors to maximize color differences in space
Usage
color_repel(
g,
coord = NULL,
groups = NULL,
nsamp = 50000,
sim = NULL,
severity = 0.5,
verbose = FALSE,
downsample = 5000,
seed = 34,
col = "colour",
autoswitch = TRUE,
out_worst = FALSE
)
Arguments
g |
ggplot plot object |
coord |
coordinates, default is inferred |
groups |
groups corresponding to color/fill, default is inferred |
nsamp |
how many random sampling color combinations to test, default 50000 |
sim |
passing a colorbind simulation function if needed |
severity |
severity of the color vision defect, between 0 and 1 |
verbose |
whether to print messages |
downsample |
downsample when too many datapoints are present |
seed |
sampling randomization seed |
col |
colour or fill in ggplot |
autoswitch |
try to switch between colour and fill automatically |
out_worst |
output the worst combination instead of best |
Value
vector of reordered colors
Examples
a <- ggplot2::ggplot(ggplot2::mpg, ggplot2::aes(displ, hwy)) +
ggplot2::geom_point(ggplot2::aes(color = as.factor(cyl)))
new_colors <- color_repel(a)
b <- a + ggplot2::scale_color_manual(values = new_colors)
[Package colorrepel version 0.1.0 Index]