Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

set_palette

Set Color Palette


Description

  • change_palette(), set_palette(): Change both color and fill palettes.

  • color_palette(): change color palette only.

  • fill_palette(): change fill palette only.

Usage

set_palette(p, palette)

change_palette(p, palette)

color_palette(palette = NULL, ...)

fill_palette(palette = NULL, ...)

Arguments

p

a ggplot

palette

Color palette. Allowed values include:

  • Grey color palettes: "grey" or "gray";

  • RColorBrewer palettes, see brewer.pal and details section. Examples of palette names include: "RdBu", "Blues", "Dark2", "Set2", ...;

  • Custom color palettes. For example, palette = c("#00AFBB", "#E7B800", "#FC4E07");

  • ggsci scientific journal palettes, e.g.: "npg", "aaas", "lancet", "jco", "ucscgb", "uchicago", "simpsons" and "rickandmorty".

...

other arguments passed to ggplot2 scale_color_xxx() and scale_fill_xxx() functions.

See Also

Examples

# Load data
data("ToothGrowth")
df <- ToothGrowth

# Basic plot
p <- ggboxplot(df, x = "dose", y = "len",
   color = "dose")
p

# Change the color palette
set_palette(p, "jco")

ggpubr

'ggplot2' Based Publication Ready Plots

v0.4.0
GPL-2
Authors
Alboukadel Kassambara [aut, cre]
Initial release
2020-06-27

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.