Choosing the right colors for your chart can be a challenging and time-consuming task that often leads to frustration.
Fortunately, the paleteer R package offers about 2728 palettes, easily accessible and ready to use in your R and ggplot2 code.
This page is an interactive tool for efficiently exploring all those palettes. In an instant, you can see a palette applied to various charts, find your favorite, and effortlessly obtain the corresponding code snippet.
Note that if you're not familiar with color customization in ggplot2, this article is a good first step.
paletteer
: the ultimate package for R colors
paletteer is one of my favorite R packages. It consolidates all available color palettes in the R ecosystem into a single package.
This means you can access over 2500 palettes with just one line of code.
The palettes are categorized as continuous or qualitative. The R Graph Gallery has a dedicated page to help you get started.
To use paletteer
, the basic syntax looks like this:
# Load necessary libraries
library(ggplot2)
library(paletteer)
# Load the data
df <- read.csv("https://raw.githubusercontent.com/holtzy/The-Python-Graph-Gallery/master/static/data/simple-scatterplot.csv")
# Create the ggplot
ggplot(df, aes(x = gdpPercap, y = lifeExp, size = pop, color = continent)) +
geom_point(size=10) +
scale_color_paletteer_d("nationalparkcolors::Acadia") +
theme(legend.position = "none")
Accessing over 2500 colors is fantastic, but having an efficient tool to explore them is essential.
That's why I created this tool! Here's how it works:
hex
colors as a string.
Bonus: Discover a "surprise me" button that randomly selects a palette for you!