The top pick for most R Studio users is the Viridis palette. It is the gold standard because it is perceptually uniform, meaning the perceived change in color is proportional to the change in data value, and it remains fully readable for people with color vision deficiency (CVD) and when printed in grayscale.
What to Look For
Choosing a color palette is not merely an aesthetic choice; it is a functional one that impacts how accurately a viewer interprets your data. When selecting a combination for your R graphs, prioritize the following technical criteria:
- Perceptual Uniformity: In a perceptually uniform palette, the distance between two colors corresponds to the actual difference in the data values. If a palette jumps from a light yellow to a dark blue abruptly, the viewer may perceive a "gap" or a "threshold" in the data where none exists.
- Color Blind Accessibility: Approximately 8% of men and 0.5% of women have some form of color vision deficiency. Red-green combinations (the default in many older software packages) are the most problematic. A professional graph must be interpretable by those with protanopia, deuteranopia, and tritanopia.
- Luminance Contrast: Contrast is the difference in brightness between colors. High luminance contrast ensures that lines and points remain distinct even if the graph is printed on a black-and-white office printer or viewed on a low-quality screen.
- Semantic Meaning: Some colors carry inherent meanings. For example, red often signifies danger or a decrease, while green signifies growth or success. If your data involves financial gains or losses, using a diverging palette with these colors is intuitive; however, using them for categorical data (like "Fruit Type") can be misleading.
- Categorical vs. Sequential vs. Diverging: You must match the palette type to the data type. Categorical palettes are for unrelated groups; sequential palettes are for ordered data (low to high); diverging palettes are for data that deviates from a central neutral point (e.g., temperature anomalies).
Viridis (The Universal Standard)
The Viridis palette is implemented via the viridis package and is now integrated into ggplot2 as scale_fill_viridis_c() and scale_color_viridis_c(). It transitions from a deep purple to a bright yellow.
Strengths: Its primary strength is accessibility. Because it varies both hue and luminance, it is virtually impossible to misinterpret. It is specifically designed to be mathematically linear in its perceived brightness, making it ideal for heatmaps and contour plots where precise value estimation is required.
Trade-offs: Some users find the yellow-purple transition too "scientific" or stark for corporate presentations that require a softer, more branded look. It is also strictly a sequential palette, meaning it cannot be used to highlight a middle neutral point.
Best For: Academic publications, scientific posters, and any dataset where accessibility is a non-negotiable requirement.
ColorBrewer (The Versatile Classic)
ColorBrewer is a curated set of palettes available through the RColorBrewer package. It provides a wide array of qualitative, sequential, and diverging schemes (e.g., "Set1", "Set3", "RdYlBu").
Strengths: The sheer variety is its greatest asset. If you need a diverging palette to show a correlation coefficient moving from -1 to 1, the "RdBu" (Red-Blue) palette is a classic choice. If you have five distinct categories of products, the "Set1" palette provides high-contrast colors that are easy to tell apart at a glance.
Trade-offs: Not all ColorBrewer palettes are color-blind friendly. Users must check the documentation or use the colorblind argument in specific functions to ensure they aren't using a problematic red-green pairing. Some of the qualitative palettes (like "Set3") can be too pale, making them disappear against a white background.
Best For: General business reporting, exploratory data analysis, and graphs requiring a specific number of distinct categories (up to 8-12).
Wes Anderson Palettes (The Aesthetic Choice)
Available via the wesanderson package, these palettes are inspired by the color schemes of films directed by Wes Anderson. They offer a more "curated" and artistic feel than the standard R defaults.
Strengths: These palettes are visually striking and move away from the "default software look." They are excellent for infographics, blog posts, or presentations where the goal is to engage the audience visually without sacrificing too much clarity. Palettes like "GrandBudapest" provide a sophisticated, muted tone that feels professional yet modern.
Trade-offs: These are primarily aesthetic. They often lack perceptual uniformity and are not designed for accessibility. Using these for a high-stakes medical or engineering report could lead to misinterpretation by color-blind viewers.
Best For: Data journalism, marketing presentations, and non-critical visual storytelling.
ggplot2 Defaults (The Quick Start)
The default colors in ggplot2 (the hue-based scale) are designed to be balanced across the color wheel, providing a wide range of distinct colors for categorical data.
Strengths: Zero setup time. They are generally well-spaced in terms of hue, meaning that for 3 to 6 categories, the colors are sufficiently distinct for most viewers. They are reliable for quick internal checks of data during the coding process.
Trade-offs: They lack a "professional" finish and can look amateurish in a final publication. The default red and green can be indistinguishable to those with deuteranopia, and the colors often lack the necessary luminance contrast for grayscale printing.
Best For: Rapid prototyping, internal data exploration, and draft-stage visualizations.
ggthemes (The Brand-Specific Approach)
The ggthemes package allows users to mimic the styles of famous publications, such as The Economist, The Wall Street Journal, and Financial Times.
Strengths: These palettes provide instant credibility by mimicking established journalistic standards. The Economist palette, for instance, uses a specific set of blues, reds, and greys that are designed for clarity in a printed magazine format. It removes the guesswork from choosing professional colors.
Trade-offs: You are locked into a specific brand's identity. If your report is for a company with its own strict branding guidelines, using a Wall Street Journal theme may look out of place or contradictory.
Best For: Financial reports, economic analysis, and professional white papers.
How to Choose
Selecting the right combination depends on three primary factors: the nature of your data, your target audience, and the final medium of delivery.
- Identify Data Type: If your data is categorical (e.g., Country A, Country B), use a qualitative palette like
RColorBrewer::Set1. If your data is ordered (e.g., Low, Medium, High), use a sequential palette likeviridis. If your data has a mid-point (e.g., Percentage Change), use a diverging palette likeRColorBrewer::RdBu. - Assess the Audience: For a general public audience or a scientific peer-review board, accessibility is the priority. Use
viridisor the color-blind safe options inRColorBrewer. For a creative or internal team,wesandersoncan add a layer of polish and interest. - Determine the Medium: Consider where the graph will live. If it is for a digital dashboard, high-saturation colors work well. If it is for a PDF that might be printed in grayscale, you must check the luminance. A simple test is to convert your graph to grayscale; if you can no longer tell the lines apart, your color combination is failing.
- Balance Budget and Time: While custom-coding hex codes (e.g.,
#FF5733) allows for perfect brand alignment, it is time-consuming. For most users, using a pre-built package likeviridisorggthemesis the most efficient way to achieve a high-quality result without spending hours on color theory.
Frequently Asked Questions
How do I apply a palette to a ggplot2 graph?
You use scale functions. For categorical colors, use scale_color_manual(values = palette_name) or scale_fill_brewer(palette = "Set1"). For continuous data, use scale_color_viridis_c().
What is the difference between scale_color and scale_fill?
scale_color affects points and lines (the outlines), while scale_fill affects the interior area of shapes like bars, boxes, and ribbons.
Can I create my own custom color palette?
Yes, you can create a vector of hex codes, such as my_colors <- c("#E41A1C", "#377EB8", "#4DAF4A"), and pass this vector into the values argument of scale_color_manual().
Why do my colors look different on different screens?
This is due to color space differences (RGB vs. CMYK) and monitor calibration. To mitigate this, stick to perceptually uniform palettes like Viridis, which are designed to be more consistent across different displays.
How many colors are too many for one graph?
Generally, more than 6-8 colors in a categorical graph become difficult for the human eye to distinguish quickly. If you have more categories, consider grouping smaller categories into an "Other" group or using facets (small multiples) instead of colors.
Bottom Line
For the vast majority of R Studio users, the Viridis palette is the best overall choice because it solves the two biggest problems in data viz: color blindness and grayscale printing. If you require a diverging scale for correlations, ColorBrewer's RdBu is the industry standard. For high-end aesthetic presentations, wesanderson is the best tool, provided accessibility is not the primary concern.