View source: R/reorder_colors.R
match_colors | R Documentation |
Often for batch processing purposes, it is important to ensure
that color centers fit using different methods are in the same
order. This function reorders a provided color palette (match_palette
)
according a provided reference palette (reference_palette
) by minimizing
their overall distance using the
Hungarian algorithm
as implemented by clue::solve_LSAP.
match_colors(reference_palette, match_palette, plotting = FALSE)
reference_palette |
The palette whose order to match. Either a character vector of colors (hex codes or color names) or an nx3 matrix in sRGB color space. |
match_palette |
The palette to reorder, same formats as
|
plotting |
Logical. Plot the ordered palettes? |
If the color palettes are wildly different, the returned order may not be especially meaningful.
A vector of color orders for match_palette
.
reorder_colors
ref_palette <- c("mediumblue", "olivedrab", "tomato2", "beige", "chocolate4")
match_palette <- c("#362C34", "#E4D3A9", "#AA4E47", "#809C35", "#49468E")
match_colors(ref_palette, match_palette, plotting = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.