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,
polychrome_recolor = FALSE,
seed = 34,
col = "colour",
autoswitch = TRUE,
layer = 1,
out_orig = FALSE,
out_worst = FALSE,
ggbuild = NULL
)
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, or use chull |
polychrome_recolor |
whether to replace the original colors with polychrome creation |
seed |
sampling randomization seed |
col |
colour or fill in ggplot |
autoswitch |
try to switch between colour and fill automatically |
layer |
layer to detect color, defaults to first |
out_orig |
output the original colors as named vector |
out_worst |
output the worst combination instead of best |
ggbuild |
already built ggplot_built object if available |
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)