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.
color_prev(
colors,
labels = TRUE,
label_color = "black",
border = FALSE,
border_color = "white",
border_size = 0.5
)
Character vector of colors. If a named vector, those names will be shown above the color blocks; otherwise, index numbers will be shown.
Logical; whether to show color name/hexcode labels
Color to use for optional labels
Logical; whether to draw border around rects
Color to use for optional borders
Size of optional borders
ggplot
object showing rects for each color
# 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)