R – palette() Function

The palette() function in base R allows users to set or view the current color palette. It can be used to select or define a custom set of colors.

Syntax: palette(value)

Parameters: 

value: an optional character vector. 
 

Set or view the current color palette

R




# R program to illustrate
# palette function
 
# Calling the palette() function
# to obtain the current palette
palette()


Output: 

[1] "black"   "red"     "green3"  "blue"    "cyan"    "magenta" "yellow" 
[8] "gray"

Set extra Graphics Palette

R




# R program to illustrate
# palette function
 
# Calling the palette() function
# to set 2 extra Graphics Palette
palette(c(palette(), "purple", "brown"))
 
# Viewing the final added Graphics Palette
palette()


Output: 

[1] "black"   "red"     "green3"  "blue"    "cyan"    "magenta" "yellow" 
[8] "gray" "purple" "brown"

Set or View the Graphics Palette in R Programming – palette() Function

In R Programming language a graphics palette refers to a set of colors that can be used to enhance the visual appearance of plots and charts. The default graphics palette in R typically consists of a range of colors, but users can customize and define their own palettes based on their preferences or specific needs.

In this article, we are going to see how to set or view the Graphic Palette in R Programming Language.

Similar Reads

R – palette() Function

The palette() function in base R allows users to set or view the current color palette. It can be used to select or define a custom set of colors....

Using Hexadecimal Color Codes

...

Defining your own palettes

...

Contact Us