Skip to main content
v2026.11,986 entries · CC-BY 4.0

RStudio Colours: Named Colours, Palettes and Editor Themes

RStudio colours covers two things: plot colours in R (colors(), col2rgb(), palette()) and the editor theme under Tools > Global Options > Appearance.

Written and maintained by CASRAI Editorial Board

Published · Last updated

On this page

“RStudio colours” means two different things: the colours R draws in plots (set with R’s own graphics functions, which RStudio simply displays) and the colours of the RStudio editor itself (a theme). The first is controlled by code, the second by a menu: Tools > Global Options > Appearance. This guide covers both, with the commands exactly as the official documentation gives them. The American spelling, “RStudio colors”, is the same topic, and R accepts both colors() and colours().

What it is used for in research

In a manuscript or thesis, colour in an R figure is a reporting choice: the same named colour or palette has to be reproducible from the script. R accepts a colour as a name, a hex string, or a positive integer that points into the current palette. For choosing scales inside ggplot2 (Brewer, viridis, manual), see ggplot colour palettes; this page covers base R and the RStudio editor, and does not repeat that material.

Install or access (official source only)

Colour functions such as colors(), col2rgb() and palette() belong to the grDevices package, which is part of R, so no extra package is needed. RStudio is the IDE from Posit; its theme settings are documented in the RStudio User Guide (docs.posit.co). Custom editor themes use the rstudioapi package.

Step-by-step: list, inspect and set colours

1. List the built-in colour names

  1. Run colors() (or colours()). The documented usage is colors(distinct = FALSE), and the value is a character vector of all built-in colour names.
  2. Run colors(distinct = TRUE) to return only colours that are distinct from one another. R’s colors() reference page gives 657 named colours, of which 502 are distinct.
  3. Use any returned name in a col= argument of a graphics function, for example plot(1:10, col = "steelblue"). The name “transparent” is not in the list but is accepted as a colour specification.

2. Convert a colour to RGB numbers

Use col2rgb(col, alpha = FALSE). The col argument may be a vector of any of the three kinds of R colour specification: a name, a hex string, or a positive integer i meaning palette()[i]. The result is an integer matrix with three rows (four if alpha = TRUE, adding opacity) and one column per colour. For example, col2rgb("steelblue") returns one column of three red, green and blue values.

3. Use a predefined palette

  1. Run palette.pals() to list the predefined palettes.
  2. Run palette.colors(n = NULL, palette = "Okabe-Ito") to select colours from one. “Okabe-Ito” is the default palette of palette.colors(); “Tableau 10” and “Alphabet” are also named in the documentation.
  3. Set the palette that integer colours index into with palette(value), for example palette(hcl.colors(8, "viridis")), which is the pattern the official example uses. Pass “default” to palette() to go back to the default.

4. Change the RStudio editor theme

  1. Open Tools > Global Options > Appearance.
  2. Pick one from the Editor theme selector. The Posit documentation names Ambiance, Chaos, Chrome and Xcode among the included themes.
  3. For a theme that is not listed, RStudio supports custom editor themes in two formats, tmTheme and rstheme. To add an rstheme, use rstudioapi::addTheme(themePath, apply, force, globally). To add a tmTheme, use rstudioapi::convertTheme(themePath, add, outputLocation, apply, force, globally), which returns the name of the newly added theme.

Output and how to read it

  • colors() prints a plain character vector of names; it contains no hex or RGB values.
  • col2rgb() prints a matrix: one column per colour you passed in, one row each for red, green and blue (plus alpha when requested).
  • palette.pals() prints palette names; palette.colors() returns colours from the one you choose.

Test a figure with a colour-vision-deficiency simulator before describing any palette as accessible in a methods section.

Troubleshooting

  • A colour name is rejected. Check it against colors(); only names in that vector (plus “transparent”) are valid names.
  • Integer colours look different after a palette change. An integer i means palette()[i], so changing the palette changes every colour specified by number. Call palette("default") to reset.
  • The editor theme did not change. The theme selector lives under Tools > Global Options > Appearance, and it changes the editor only, not the colours inside your plots.

Free alternatives: other ways to specify a colour in R

Specification What it is Source function
Colour name An entry from the built-in names colors()
Hex string One of the three colour specification kinds accepted by col2rgb() col2rgb()
Positive integer Index i into palette() palette()
Predefined palette Colours selected from a named palette such as “Okabe-Ito” palette.colors()

All four are part of base R and free to use. For related plotting tasks see heatmaps in R and scatterplots in R; for the Python equivalent see Seaborn colour palettes.

FAQ

How many colours does R have?

The R reference page’s example comments give 657 named colours, 502 of them distinct when you call colors(distinct = TRUE).

How do I see the RGB values of an R colour?

Use col2rgb(), for example col2rgb("steelblue"), and add alpha = TRUE for opacity.

How do I change the RStudio theme?

Go to Tools > Global Options > Appearance and choose from the Editor theme selector; custom themes are added with rstudioapi.

Is it RStudio colours or RStudio colors?

Same topic. R provides both colors() and colours(), and they return the same built-in names.

Related: Quarto vs R Markdown if your coloured figures end up in a report.

Sources (official docs)

Follow CASRAI

Research-administration guidance, standards updates and independent tool reviews.

Ask CASRAI · free to try

Ask about RStudio Colours: Named Colours, Palettes and Editor Themes

2 free questions a day, no account.

An AI assistant for research: funder rules, compliance, methods and publishing. It links the sources behind its answers and labels answers that come from a web search.

Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.

Works on this site and inside Claude, Cursor and the AI tools you already use.

Everything CASRAI publishes — this page, the dictionary, the guides and the news — stays open to read, with no account and no card.

Referenced across the research world

University of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logoUniversity of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logo
  • University of Cambridge logo
  • Columbia University logo
  • Crossref logo
  • University of Edinburgh logo
  • Harvard University logo
  • University of Oxford logo
  • Princeton University logo
  • Stanford School of Medicine logo
  • University College London logo
  • ORCID logo

View CASRAI adoption →