Adding Colors to Charts in R Programming

There are hundreds of charts and graphs present in R. For example, bar plot, box plot, mosaic plot, dot chart, coplot, histogram, pie chart, scatter graph, etc. We can visually enhance our plots and make them more attractive through colors. The col graphical parameter is brought into use for this purpose. The desired color’s name can be expressed in the string. 

Syntax: barplot( A, col=color_name)

Example: 

R




# Creating a list
temp<-c(5, 10, 15, 20, 25)
   
# Barplot with default color
barplot(temp, main ="By default")
   
# Barplot with green color
barplot(temp, col ="green",
        main ="With coloring")


Output: 

Adding Colors to Charts in R Programming

R Programming language is mostly used for statistics and data analytics purposes to represent the data graphically in the software. To represent those data graphically, charts and graphs are used in R. 

Similar Reads

Adding Colors to Charts in R Programming

There are hundreds of charts and graphs present in R. For example, bar plot, box plot, mosaic plot, dot chart, coplot, histogram, pie chart, scatter graph, etc. We can visually enhance our plots and make them more attractive through colors. The col graphical parameter is brought into use for this purpose. The desired color’s name can be expressed in the string....

R – Colors to Charts

...

Contact Us