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:
- Color Specification:
Thecolors
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
). - Pie Chart Creation:
Thepie()
function is then used to create a pie chart using the data in thediscoveries
vector. Thecol
parameter is set to thecolors
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.