Defining your own palettes

Here we will make our own palettes, for this, we will make the vectors along with hex triplets and R color names and then plot the chart with these color names.

R




colors <- c("#A7A7A7",
 "forestgreen",
 "gold")
 
pie(discoveries, col = colors)


Output:

  1. Color Specification:
    The colors vector contains three color values specified as hexadecimal color codes. In this example, the colors are light gray (#A7A7A7), forest green (forestgreen), and gold (gold).
  2. Pie Chart Creation:
    The pie() function is then used to create a pie chart using the data in the discoveries vector. The col parameter is set to the colors vector, indicating that each segment of the pie chart should be filled with the corresponding color.


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