Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Selected Reading
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

Advertisements
