- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to create a graph in base R with multiple shades of a particular color?
To create a graph in base R with multiple shades of a particular color, we can follow the below steps −
- First of all, create color shades using colorRampPalette then plot a graph.
- Use the color shades to create the graph.
Example 1
Create the color shades
Using colorRampPalette function to create the color shades between red and darkred color then creating the plot −
Color<-colorRampPalette(c("red","darkred")) plot(1:5,col=Color(5),pch=16,cex=2)
On executing, the above script generates the below output(this output will vary on your system due to randomization) −
Output
Example 2
Create the color shades
Using colorRampPalette function to create the color shades between blue and darkblue color then creating the plot −
Color<-colorRampPalette(c("blue","darkblue")) plot(1:8,col=Color(8),pch=16,cex=2)
Output
- Related Articles
- How to create a horizontal line in ggplot2 graph with different color in R?
- How to create multiple plots of different sizes in base R?
- How to create boxplot for multiple categories with long names in base R?
- How to create a circle filled with a color in R?
- How to create boxplot for multiple categories in base R?
- How to create a circle with different color border in R?
- How to create a histogram with dots instead of bars in base R?
- How to create a boxplot with log of the variable in base R?
- How to create a vector with all dates in a particular year in R?
- How to change the color of a particular bar using geom_bar in R?
- How to change the color of gridlines of a ggplot2 graph in R?
- How to create a plot with dashed regression line in base R?
- How to change the plot border color of a ggplot2 graph in R?
- How to create a plot in base R with tick marks of larger size?
- How to create a horizontal boxplot in base R?

Advertisements