Description Usage Arguments Value Examples
This makes a simple ggplot
with boxes side by side of each color in a vector. Numbers along the top show the position of the color in the vector. Optional labels are shown with the name or hexcode of each color; if ggfittext
is installed, the labels will be scaled to fit in the rectangles.
1 2 3 4 5 6 7 8 | color_prev(
colors,
labels = TRUE,
label_color = "black",
border = FALSE,
border_color = "white",
border_size = 0.5
)
|
colors |
Character vector of colors. If a named vector, those names will be shown above the color blocks; otherwise, index numbers will be shown. |
labels |
Logical; whether to show color name/hexcode labels |
label_color |
Color to use for optional labels |
border |
Logical; whether to draw border around rects |
border_color |
Color to use for optional borders |
border_size |
Size of optional borders |
ggplot
object showing rects for each color
1 2 3 | # Paul Tol's colorblind-friendly palette, from ggthemes
tol <- c("#332288", "#88CCEE", "#44AA99", "#117733", "#999933", "#DDCC77", "#CC6677")
color_prev(tol, border = TRUE, border_size = 1)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.