Learn R Programming

colouR (version 0.1.1)

plotPalette: plotPalette

Description

Plot a color palette from a data frame. This function takes a vector of colours or a data frame with a column of colors and plots the colors as a color palette.

Usage

plotPalette(df, color_col)

Value

A ggplot2 plot object displaying the color palette.

Arguments

df

A vector of colours or a data frame containing a column with colors in hexadecimal format.

color_col

A character string representing the name of the column containing the colors.

Examples

Run this code
# Create a sample data frame with colors
colors_df <- data.frame(
  color = c("#FF0000", "#00FF00", "#0000FF", "#FFFF00", "#FF00FF")
)

# Plot the color palette with default bar height
plotPalette(colors_df, "color")

Run the code above in your browser using DataLab