Discrete

If you wish to specify a default, discrete colour scale such as that produced by scale_colour_brewer() use the ggplot2.discrete.colour option. Similarly, use the option ggplot2.discrete.fill for a discrete fill scale.

Default Discrete Scales

library(ggplot2)

ggplot(mtcars, aes(hp, mpg, color = factor(cyl), fill = factor(cyl))) + geom_point()

Created on 2021-07-01 by the reprex package (v1.0.0)

Custom Discrete Scales

library(ggplot2)

scale_colour_brewer_d <- function(..., palette = "Dark2") {
  scale_colour_brewer(..., palette = palette )
}

scale_fill_brewer_d <- function(..., palette = "Dark2") {
  scale_fill_brewer(..., palette = palette)
}

options(
  ggplot2.discrete.colour = scale_colour_brewer_d,
  ggplot2.discrete.fill = scale_fill_brewer_d
)

ggplot(mtcars, aes(hp, mpg, color = factor(cyl), fill = factor(cyl))) + geom_point()

Created on 2021-07-01 by the reprex package (v1.0.0)

Continuous

If you wish to specify a default, continuous color scale, you will need to use scale_colour_distiller() instead of scale_colour_brewer(). Similarly, use scale_fill_distiller() as opposed to scale_fill_brewer() for a continuous fill scale. You will also use the options ggplot2.continuous.colour and ggplot2.continuous.fill respectively.

Default Continuous Scales

library(ggplot2)

ggplot(mtcars, aes(hp, mpg, color = cyl, fill = cyl)) + geom_point()

Created on 2021-07-01 by the reprex package (v1.0.0)

Custom Continuous Scales

library(ggplot2)

scale_colour_brewer_c <- function(..., palette = "Dark2") {
  scale_colour_distiller(..., palette = palette )
}

scale_fill_brewer_c <- function(..., palette = "Dark2") {
  scale_fill_distiller(..., palette = palette)
}

options(
  ggplot2.continuous.colour = scale_colour_brewer_c,
  ggplot2.continuous.fill = scale_fill_brewer_c
)

ggplot(mtcars, aes(hp, mpg, color = cyl, fill = cyl)) + geom_point()

Created on 2021-07-01 by the reprex package (v1.0.0)

Answer from the-mad-statter on Stack Overflow
🌐
ProjectPro
projectpro.io › recipes › use-rcolorbrewer-palette-for-plotting-graphs-ggplot2
How to use Rcolorbrewer palette for plotting graphs using ggplot2 in R -
December 26, 2022 - The r color palette is used for changing the default color of graphs plotted using different libraries. ggplot uses the following syntax for changing colors of various plots: -scale_fill_brewer (palette="") where, palette = different color schemes.
People also ask

What is the difference between fill and colour in ggplot2?
fill paints the interior of areas (boxes, bars, violins), while colour controls points, lines, and outlines. For point and line geoms there is no interior, so set colour; for a box with a coloured border around a coloured interior, set both (e.g. geom_boxplot(fill = "#3a86d4", colour = "grey25")).
🌐
sthda.com
sthda.com › learn › data visualization › ggplot2 colours in r (live, interactive)
ggplot2 Colours in R (Live, Interactive) – Datanovia
How do I apply one of these palettes to a ggplot2 chart?
Map the palette to the relevant scale. For a discrete grouping use scale_color_viridis_d() / scale_fill_viridis_d(), scale_color_brewer(palette = "Set2"), or a manual vector with scale_color_manual(values = my_colors); for a numeric variable use the _c twins (scale_fill_viridis_c()). The dedicated ggplot2 Colors lesson covers color vs fill, coloring by group, and continuous gradients in full.
🌐
datanovia.com
datanovia.com › blog › r color palettes: the complete reference
R Color Palettes: The Complete Reference – Datanovia
How do I set my own custom colours in a ggplot2 plot?
Add scale_fill_manual(values = ...) for fills (or scale_colour_manual() for points and lines) and pass one colour per group, by name or hex. You can name the values like c(OJ = "#3a86d4", VC = "#f5a524") to bind a specific colour to a specific group regardless of order.
🌐
sthda.com
sthda.com › learn › data visualization › ggplot2 colours in r (live, interactive)
ggplot2 Colours in R (Live, Interactive) – Datanovia
🌐
Datanovia
datanovia.com › blog › r color palettes: the complete reference
R Color Palettes: The Complete Reference – Datanovia
July 12, 2026 - Tie it back to the catalog: viridis is a sequential, perceptually-uniform ramp; RColorBrewer ships all three types (and flags the colourblind-safe ones); the scientific-journal and Okabe–Ito sets are qualitative; and a diverging set like RdBu is the right call whenever your data have a meaningful middle. When none of the ready-made sets fit, design your own with these same three ideas. The viridis scales are perceptually uniform, colorblind-safe, and greyscale-safe. ggplot2 ships them built in (no extra package needed for the scales), and viridisLite gives you the raw colors for base R.
🌐
Ajsmit
ajsmit.github.io › Intro_R_Official › brewing.html
Chapter 7 Brewing colours in ggplot2 | Intro R Workshop: Data Manipulation, Analysis, and Visualisation
Central to the purpose of ggplot2 is the creation of beautiful figures. For this reason there are many built in functions that we may use in order to have precise control over the colours we use, as well as additional packages that extend our options even further. The RColorBrewer package should have been installed on your computer and activated automatically when we installed and activated the tidyverse.
🌐
RDocumentation
rdocumentation.org › packages › ggplot2 › versions › 1.0.1 › topics › scale_colour_brewer
scale_colour_brewer function - RDocumentation
ColorBrewer provides sequential, diverging and qualitative colour schemes which are particularly suited and tested to display discrete values (levels of a factor) on a map. ggplot2 can use those colours in discrete scales. It also allows to smoothly interpolate 6 colours from any palette to ...
🌐
STHDA
sthda.com › learn › data visualization › ggplot2 colours in r (live, interactive)
ggplot2 Colours in R (Live, Interactive) – Datanovia
ggplot2 ships with RColorBrewer scales: scale_fill_brewer(palette = ...) and scale_colour_brewer(palette = ...). Name a qualitative palette like "Set2" or "Dark2" for categorical groups.
Find elsewhere
Top answer
1 of 1
5

Discrete

If you wish to specify a default, discrete colour scale such as that produced by scale_colour_brewer() use the ggplot2.discrete.colour option. Similarly, use the option ggplot2.discrete.fill for a discrete fill scale.

Default Discrete Scales

library(ggplot2)

ggplot(mtcars, aes(hp, mpg, color = factor(cyl), fill = factor(cyl))) + geom_point()

Created on 2021-07-01 by the reprex package (v1.0.0)

Custom Discrete Scales

library(ggplot2)

scale_colour_brewer_d <- function(..., palette = "Dark2") {
  scale_colour_brewer(..., palette = palette )
}

scale_fill_brewer_d <- function(..., palette = "Dark2") {
  scale_fill_brewer(..., palette = palette)
}

options(
  ggplot2.discrete.colour = scale_colour_brewer_d,
  ggplot2.discrete.fill = scale_fill_brewer_d
)

ggplot(mtcars, aes(hp, mpg, color = factor(cyl), fill = factor(cyl))) + geom_point()

Created on 2021-07-01 by the reprex package (v1.0.0)

Continuous

If you wish to specify a default, continuous color scale, you will need to use scale_colour_distiller() instead of scale_colour_brewer(). Similarly, use scale_fill_distiller() as opposed to scale_fill_brewer() for a continuous fill scale. You will also use the options ggplot2.continuous.colour and ggplot2.continuous.fill respectively.

Default Continuous Scales

library(ggplot2)

ggplot(mtcars, aes(hp, mpg, color = cyl, fill = cyl)) + geom_point()

Created on 2021-07-01 by the reprex package (v1.0.0)

Custom Continuous Scales

library(ggplot2)

scale_colour_brewer_c <- function(..., palette = "Dark2") {
  scale_colour_distiller(..., palette = palette )
}

scale_fill_brewer_c <- function(..., palette = "Dark2") {
  scale_fill_distiller(..., palette = palette)
}

options(
  ggplot2.continuous.colour = scale_colour_brewer_c,
  ggplot2.continuous.fill = scale_fill_brewer_c
)

ggplot(mtcars, aes(hp, mpg, color = cyl, fill = cyl)) + geom_point()

Created on 2021-07-01 by the reprex package (v1.0.0)

🌐
Databrewer
databrewer.co › R › visualization › 15-ggplot2-color-brewer-palette
A Complete Guide on the “brewer” Color Palettes in ggplot2
scale_color_brewer(), scale_color_distiller(), and scale_color_fermenter() (and the scale_fill_* functions) are all built in the ggplot2 package. However, in order to display the brewer’s available palette names and colors, or to extract colors hex codes from the brewer palettes, you need to additionally load the RColorBrewer package.
🌐
Jose M Sallan blog
jmsallan.netlify.app › blog › the-brewer-palettes
The Brewer palettes - Jose M Sallan blog - Netlify
Sequential, diverging and qualitative colour scales from ColorBrewer https://ggplot2.tidyverse.org/reference/scale_brewer.html · Built with R 4.1.0, tidyverse 1.3.1 and RColorBrewer 1.1-2
🌐
GeeksforGeeks
geeksforgeeks.org › r language › how-to-change-the-color-of-points-for-ggplot2-scatterplot-using-colorbrewer-in-r
How to Change the Color of Points for ggplot2 Scatterplot Using ColorBrewer in R - GeeksforGeeks
July 23, 2025 - By combining RColorBrewer palettes with ggplot2 customization options like legend labels, point size, and transparency, you can create highly effective and visually attractive scatter plots in R.
🌐
R Graph Gallery
r-graph-gallery.com › package › rColorBrewer.html
Access mutliple color palettes with RColorBrewer
Since RColorBrewer is an extension of ggplot2, you can use it to customize the color of your plots.
🌐
R-statistics
r-statistics.co › home › ggplot2 scale_color_brewer() in r: colorbrewer palettes
ggplot2 scale_color_brewer() in R: ColorBrewer Palettes
June 21, 2026 - The scale_color_brewer() function in ggplot2 applies named ColorBrewer palettes to discrete groups. ColorBrewer palettes are designed for cartography but work great for any categorical visualization.
🌐
RPubs
rpubs.com › bruno-ponne › 1010837
RPubs - Using scale_color_brewer to choose you ggplot2 colors
March 3, 2023 - Using scale_color_brewer to choose you ggplot2 colors · by Bruno Ponne · Last updated over 3 years ago · Hide Comments (–) Share Hide Toolbars ·
🌐
Beanumber
beanumber.github.io › sds192 › lab-colorbrewer-ggthemes.html
ColorBrewer and ggthemes
That looks pretty nice, but we could spend an awful lot of time making tiny tweaks to color palettes. Luckily Cynthia Brewer over at ColorBrewer has come up with some really good ones we can borrow! Let’s load the RColorBrewer library and check it out.
🌐
Cookbook-r
cookbook-r.com › Graphs › Colors_(ggplot2)
Colors (ggplot2)
You can also use other color scales, such as ones taken from the RColorBrewer package. See the chart of RColorBrewer palettes below.
🌐
Codingthepast
codingthepast.com › 2023 › 02 › 22 › Military-Expenses.html
Learn To Use scale_color_brewer To Change Colors In ggplot2
August 23, 2024 - As mentioned above, scale_color_brewer employs ColorBrewer palettes. These are originally available from the RColorBrewer package, but are also automatically loaded by ggplot2.
🌐
Datavizpyr
datavizpyr.com › home › introduction to color palettes in r with rcolorbrewer
Introduction to Color Palettes in R with RColorBrewer - Data Viz with Python and R
September 6, 2025 - The RColorBrewer palettes work seamlessly with ggplot2. Depending on whether your variable is categorical or continuous, you will use different functions to apply palettes.