You can bin/coarse-grain the continuous values to give them a discrete-ordered value to map to the discrete 8 to 12 colors included in your Brewer palette of choice.

But I think the solution you are looking for is to "distill" them with the scale_color_distiller() or scale_fill_distiller() functions already included in ggplot2, effectively converting them to a continuous color scale. Documentation and examples are provided in some canonical locations:

  • https://ggplot2.tidyverse.org/reference/scale_brewer.html
  • https://ggplot2-book.org/scale-colour.html#colour-continuous
Answer from Paul 'Joey' McMurdie on Stack Overflow
🌐
Tidyverse
ggplot2.tidyverse.org › reference › scale_brewer.html
Sequential, diverging and qualitative colour scales from ColorBrewer — scale_colour_brewer • ggplot2
Other arguments passed on to discrete_scale(), continuous_scale(), or binned_scale(), for brewer, distiller, and fermenter variants respectively, to control name, limits, breaks, labels and so forth. ... If a string, will use that named palette. If a number, will index into the list of palettes of appropriate type. The list of available palettes can found in the Palettes section. ... Sets the order of colours in the scale. If 1, the default, colours are as output by RColorBrewer::brewer.pal().
🌐
R Graph Gallery
r-graph-gallery.com › 38-rcolorbrewers-palettes.html
R Color Brewer’s palettes
The RColorBrewer package offers several color palette for R. This post displays all of them to help you pick the right one.
🌐
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 - RColorBrewer: Continuous mapping with scale_color_distiller() About 8% of men and 0.5% of women live with some form of color vision deficiency, which means charts using poor color choices can be misleading or unreadable for many viewers. The RColorBrewer package helps solve this by marking which palettes are safe for color-blind audiences.
🌐
Plotly
plotly.com › r › builtin-colorscales
Built-in continuous color scales in R
Plotly R supports a large number of built-in continuous color scales. These can be viewed and used with the 'RColorBrewer' package.
🌐
Seascapemodels
seascapemodels.org › posts › 2015-07-19-brewer_colour_palettes › 2015-07-19-brewer_colour_palettes.html
Making continuous colour palettes with RColorBrewer – Seascapemodels
July 7, 2016 - Choosing a few colours will emphasis zones in elevation, for instance, maybe you want to represent different vegetation zones that change with altitude. Whereas, a continuous palette will obviously represent the data as more of a gradient. library(RColorBrewer) bluecols <- brewer.pal(9, 'Blues')
🌐
R-lib
scales.r-lib.org › reference › pal_brewer.html
Colour Brewer palette (discrete) — pal_brewer • scales
If 1, the default, colours are as output by RColorBrewer::brewer.pal(). If -1, the order of colours is reversed. ... show_col(pal_brewer()(10)) #> Warning: n too large, allowed maximum for palette Blues is 9 #> Returning the palette you asked for with that many colors show_col(pal_brewer("div")(5)) show_col(pal_brewer(palette = "Greens")(5)) # Can use with gradient_n to create a continuous ...
Find elsewhere
🌐
Jiffyclub
jiffyclub.github.io › palettable › colorbrewer › sequential
Colorbrewer : Sequential
Palettable · Home · Colorbrewer · Colorbrewer : Sequential · Colorbrewer : Sequential · Contents · Previews · Blues_3 · Blues_4 · Blues_5 · Blues_6 · Blues_7 · Blues_8 · Blues_9 · BuGn_3 · BuGn_4 · BuGn_5 · BuGn_6 · BuGn_7 · BuGn_8 · BuGn_9 ·
🌐
Rdrr.io
rdrr.io › cran › RColorBrewer › man › ColorBrewer.html
ColorBrewer: ColorBrewer palettes in RColorBrewer: ColorBrewer Palettes
April 4, 2022 - All the sequential palettes are available in variations from 3 different values up to 9 different values.
🌐
R CHARTS
r-charts.com › color-palettes
R Color Palettes [497 continuous and discrete palettes] | R CHARTS
A collection of 497 ready to use palettes from 16 popular R packages divided into continuous (30 samples), discrete and dynamic palettes
🌐
Databrewer
databrewer.co › R › visualization › 15-ggplot2-color-brewer-palette
A Complete Guide on the “brewer” Color Palettes in ggplot2
When the type of the variable is mismatched with the color scale syntax, it’ll generate an error message typically like: Error: Continuous value supplied to discrete scale. 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.
🌐
Datanovia
datanovia.com › blog › r color palettes: the complete reference
R Color Palettes: The Complete Reference – Datanovia
July 12, 2026 - The palette families worth knowing in R — and when to reach for each. viridis (the safe default), RColorBrewer (sequential / diverging / qualitative), grey, scientific-journal (ggsci), Wes Anderson, and base-R palettes (rainbow, heat.colors…).
🌐
R-bloggers
r-bloggers.com › r bloggers › how to expand color palette with ggplot and rcolorbrewer
How to expand color palette with ggplot and RColorBrewer | R-bloggers
September 13, 2013 - Finally, the same example using in place palette constructor with different choice of library palette: ggplot(mtcars) + geom_histogram(aes(factor(hp), fill=factor(hp))) + scale_fill_manual(values = colorRampPalette(brewer.pal(12, "Accent"))(colourCount)) + theme(legend.position="bottom") + guides(fill=guide_legend(nrow=2)) There are quite a few more scale functions to choose from depending on aesthetics type (colour, fill), color types (gradient, hue, etc.), data values (discrete or continuous).
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)

🌐
Ajsmit
ajsmit.github.io › Intro_R_Official › brewing.html
Chapter 7 Brewing colours in ggplot2 | Intro R Workshop: Data Manipulation, Analysis, and Visualisation
The RColorBrewer package should have been installed on your computer and activated automatically when we installed and activated the tidyverse. We will use this package for its lovely colour palettes. Let’s spruce up the previous continuous colour scale figure now.
🌐
Reddit
reddit.com › r/rstats › r color brewer
r/rstats on Reddit: R color brewer
February 21, 2019 -

I am playing around with this library. I had some questions about diffferent palettes. Let's take the first color set in the sequential palette
For example, I use brewer.pal(9,"YlOrRd") I get the following colors [1] "#FFFFCC" "#FFEDA0" "#FED976" "#FEB24C" "#FD8D3C" "#FC4E2A" "#E31A1C" [8] "#BD0026" "#800026"

But when I want to use the first five colors of the set, brewer.pal(5,"YlOrRd"), I get the following output [1] "#FFFFB2" "#FECC5C" "#FD8D3C" "#F03B20" "#BD0026"

Why I am I getting different colors in the same set, just by changing the number of colors I want?

Also when I notice in brewer.pal(5,"YlOrRd"),some of the colors like "#F03B20" are not even there in the brewer.pal(9,"YlOrRd"). What exactly is this doing?

🌐
Kwstat
kwstat.github.io › pals › reference › brewer.html
ColorBrewer palettes — brewer • pals
Source: R/colors_continuous.R · brewer.Rd · These functions provide a unified access to the ColorBrewer palettes.
🌐
RDocumentation
rdocumentation.org › packages › ggplot2 › versions › 1.0.1 › topics › scale_colour_brewer
scale_colour_brewer function - RDocumentation
ColorBrewer provides sequential, ... 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 a continuous scale (6 colours per palette gives nice gradients; more results in more saturated colours ...