Wrapper to reorder ggplot colors to maximize color differences in space
gg_color_repel(
g = ggplot2::last_plot(),
col = "colour",
sim = NULL,
severity = 0.5,
verbose = FALSE,
downsample = 5000,
nsamp = 50000,
polychrome_recolor = FALSE,
seed = 34,
autoswitch = TRUE,
layer = 1,
out_orig = FALSE,
out_worst = FALSE,
repel_label = FALSE,
encircle = FALSE,
encircle_alpha = 0.25,
encircle_expand = 0.02,
encircle_shape = 0.5,
encircle_threshold = 0.01,
encircle_nmin = 0.01,
mascarade = FALSE,
ggbuild = NULL,
...
)new ggplot object
ggplot plot object
colour or fill in ggplot
passing a colorbind simulation function if needed
severity of the color vision defect, between 0 and 1
whether to print messages
downsample when too many datapoints are present
how many random sampling color combinations to test, default 50000
whether to replace the original colors with polychrome creation
sampling randomization seed
try to switch between colour and fill automatically
layer to detect color, defaults to first
output the original colors as named vector
output the worst combination instead of best
whether to add centroid labels with ggrepel
whether to draw geom_encircle by cluster
alpha argument passed to geom_encircle
expand argument passed to geom_encircle
shape/smoothing argument passed to geom_encircle
threshold for removing outliers
number of near neighbors for removing outliers
use mascarade package to outline clusters
already built ggplot_built object if available
passed to repel_label
a <- ggplot2::ggplot(ggplot2::mpg, ggplot2::aes(displ, hwy)) +
ggplot2::geom_point(ggplot2::aes(color = as.factor(cyl)))
b <- gg_color_repel(a, col = "colour")
Run the code above in your browser using DataLab