SlideShare a Scribd company logo
www.r-squared.in/git-hub
dataCrunch
Data Visualization With R
Learn To Add/Modify Color To Plots
dataCrunchCourse Material
Slide 2
All the material related to this course are available at our Website
Slides can be viewed at SlideShare
Scripts can be downloaded from GitHub
Videos can be viewed on our Youtube Channel
dataCrunch
Color
Slide 3
dataCrunchColor
Slide 4
In this section, we will learn to add colors to the following using the col argument:
● Plot Symbol
● Title & Subtitle
● Axis
● Axis Labels
● Foreground
dataCrunchSyntax
Slide 5
Feature Argument Value Example
Symbol col
String
Hexadecimal
RGB
"blue"
Title col.main "#0000ff"
Subtitle col.sub rgb(0, 0, 1)
Axis col.axis "red"
Label col.lab "#ff0000"
Foreground fg rgb(1, 0, 0)
The col argument can be used along with main, sub, axis and lab arguments to specify the color of
the title, subtitle, axes and the labels.
dataCrunchColor: Symbol
Slide 6
# modify color of the plot
plot(mtcars$disp, mtcars$mpg,
col= "red")
OR
plot(mtcars$disp, mtcars$mpg,
col = "#ff0000")
OR
plot(mtcars$disp, mtcars$mpg,
col = rgb(1, 0, 0))
Description
Let us begin by adding color to the symbol in the
plot using the col argument in the plot()
function.
Code
dataCrunchColor: Title
Slide 7
# modify the color of the title
plot(mtcars$disp, mtcars$mpg,
main = "Displacement vs Miles Per Gallon",
col.main = "blue")
OR
plot(mtcars$disp, mtcars$mpg,
main = "Displacement vs Miles Per Gallon",
col.main = "#0000ff")
OR
plot(mtcars$disp, mtcars$mpg,
main = "Displacement vs Miles Per Gallon",
col.main = rgb(0, 0, 1))
Description
The color of the title can be modified by using the
col.main argument in the plot() function.
Code
dataCrunchColor: Subtitle
Slide 8
# modify the color of the subtitle
plot(mtcars$disp, mtcars$mpg,
sub= "Displacement vs Miles Per Gallon",
col.sub = "blue")
OR
plot(mtcars$disp, mtcars$mpg,
sub= "Displacement vs Miles Per Gallon",
col.sub = "#0000ff")
OR
plot(mtcars$disp, mtcars$mpg,
sub= "Displacement vs Miles Per Gallon",
col.sub = rgb(0, 0, 1))
Description
The color of the subtitle can be modified by using
the col.sub argument in the plot() function.
Code
dataCrunchColor: Axis
Slide 9
# modify the color of the axis
plot(mtcars$disp, mtcars$mpg,
col.axis = "blue")
OR
plot(mtcars$disp, mtcars$mpg,
col.axis = "#0000ff")
OR
plot(mtcars$disp, mtcars$mpg,
col.axis = rgb(0, 0, 1))
Description
The color of the axis can be modified by using the
col.axis argument in the plot() function.
Code
dataCrunchColor: Labels
Slide 10
# modify the color of the labels
plot(mtcars$disp, mtcars$mpg,
xlab = "Displacement",
ylab = "Miles Per Gallon",
col.lab = "blue")
Description
The color of the labels can be modified by using the
col.lab argument in the plot() function.
Code
dataCrunchColor: Foreground
Slide 11
# modify the color of the foreground
plot(mtcars$disp, mtcars$mpg,
fg= "red")
Description
The color of the foreground can be modified by
using the fg argument in the plot() function.
Code
dataCrunchColor: Using title() function
Slide 12
# Create a basic plot
plot(mtcars$disp, mtcars$mpg, ann= FALSE)
# modify color using title() function
title(main = "Displacement vs Miles Per Gallon",
xlab = "Displacement",
ylab = "Miles Per Gallon",
col.main = "blue", col.lab = "red")
Description
The colors of the title, subtitle and the labels can be
modified using the title() function as well. Let us
try it out:
Code
dataCrunch
Slide 13
Visit dataCrunch for
tutorials on:
→ R Programming
→ Business Analytics
→ Data Visualization
→ Web Applications
→ Package Development
→ Git & GitHub
Ad

Recommended

Data Visualization With R: Learn To Modify Font Of Graphical Parameters
Data Visualization With R: Learn To Modify Font Of Graphical Parameters
Rsquared Academy
 
Data Visualization With R: Introduction
Data Visualization With R: Introduction
Rsquared Academy
 
R Data Visualization: Learn To Add Text Annotations To Plots
R Data Visualization: Learn To Add Text Annotations To Plots
Rsquared Academy
 
R Data Visualization Tutorial: Bar Plots
R Data Visualization Tutorial: Bar Plots
Rsquared Academy
 
Data Visualization With R: Learn To Modify Title, Axis Labels & Range
Data Visualization With R: Learn To Modify Title, Axis Labels & Range
Rsquared Academy
 
Data Visualization With R: Learn To Combine Multiple Graphs
Data Visualization With R: Learn To Combine Multiple Graphs
Rsquared Academy
 
NCCU: Statistics in the Criminal Justice System, R basics and Simulation - Pr...
NCCU: Statistics in the Criminal Justice System, R basics and Simulation - Pr...
The Statistical and Applied Mathematical Sciences Institute
 
R Programming: Numeric Functions In R
R Programming: Numeric Functions In R
Rsquared Academy
 
Conversion from infix to prefix using stack
Conversion from infix to prefix using stack
Haqnawaz Ch
 
A Survey Of R Graphics
A Survey Of R Graphics
Dataspora
 
Data structures
Data structures
Rokonuzzaman Rony
 
Chapter13 two-dimensional-array
Chapter13 two-dimensional-array
Deepak Singh
 
Ds list of experiments ce
Ds list of experiments ce
Shraddha Patel
 
Queue
Queue
A. S. M. Shafi
 
Lecture 1 mte 407
Lecture 1 mte 407
rumanatasnim415
 
Lecture 1 mte 407
Lecture 1 mte 407
rumanatasnim415
 
The matplotlib Library
The matplotlib Library
Haim Michael
 
CS8391 Data Structures Part B Questions Anna University
CS8391 Data Structures Part B Questions Anna University
P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai
 
Lecture 07
Lecture 07
sohelranasweet
 
H Alg2 091409
H Alg2 091409
Mr. Smith
 
Tools for research plotting
Tools for research plotting
Nimrita Koul
 
Functional programming in Swift
Functional programming in Swift
John Pham
 
2.1.2 functions and their graphs
2.1.2 functions and their graphs
Northside ISD
 
TikZ for economists
TikZ for economists
kevingoulding
 
Assignment3
Assignment3
Mahmoud
 
Function recap
Function recap
alish sha
 
SMU BCA SEM 1 FALL 2016 ASSIGNMENTS
SMU BCA SEM 1 FALL 2016 ASSIGNMENTS
solved_assignments
 
Codes and conventions of a contents page
Codes and conventions of a contents page
baileyharland
 
Resume 786
Resume 786
Shaik Sulaiman
 
ajeet kumar Delhi 12+ yrs (3+ AS AN HR RECRUITER)
ajeet kumar Delhi 12+ yrs (3+ AS AN HR RECRUITER)
Ajeet Kumar198282
 

More Related Content

What's hot (19)

Conversion from infix to prefix using stack
Conversion from infix to prefix using stack
Haqnawaz Ch
 
A Survey Of R Graphics
A Survey Of R Graphics
Dataspora
 
Data structures
Data structures
Rokonuzzaman Rony
 
Chapter13 two-dimensional-array
Chapter13 two-dimensional-array
Deepak Singh
 
Ds list of experiments ce
Ds list of experiments ce
Shraddha Patel
 
Queue
Queue
A. S. M. Shafi
 
Lecture 1 mte 407
Lecture 1 mte 407
rumanatasnim415
 
Lecture 1 mte 407
Lecture 1 mte 407
rumanatasnim415
 
The matplotlib Library
The matplotlib Library
Haim Michael
 
CS8391 Data Structures Part B Questions Anna University
CS8391 Data Structures Part B Questions Anna University
P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai
 
Lecture 07
Lecture 07
sohelranasweet
 
H Alg2 091409
H Alg2 091409
Mr. Smith
 
Tools for research plotting
Tools for research plotting
Nimrita Koul
 
Functional programming in Swift
Functional programming in Swift
John Pham
 
2.1.2 functions and their graphs
2.1.2 functions and their graphs
Northside ISD
 
TikZ for economists
TikZ for economists
kevingoulding
 
Assignment3
Assignment3
Mahmoud
 
Function recap
Function recap
alish sha
 
SMU BCA SEM 1 FALL 2016 ASSIGNMENTS
SMU BCA SEM 1 FALL 2016 ASSIGNMENTS
solved_assignments
 

Viewers also liked (14)

Codes and conventions of a contents page
Codes and conventions of a contents page
baileyharland
 
Resume 786
Resume 786
Shaik Sulaiman
 
ajeet kumar Delhi 12+ yrs (3+ AS AN HR RECRUITER)
ajeet kumar Delhi 12+ yrs (3+ AS AN HR RECRUITER)
Ajeet Kumar198282
 
Resume_Networking_profile__Harish_New_CV
Resume_Networking_profile__Harish_New_CV
Harish Raghav
 
Broad bean diseases A Lecture By Allah Dad Khan Provincial Coordinator IPM MI...
Broad bean diseases A Lecture By Allah Dad Khan Provincial Coordinator IPM MI...
Mr.Allah Dad Khan
 
Ordnance School Diploma
Ordnance School Diploma
Antoine Ngemhe
 
Pepipost
Pepipost
Dibya Prakash Sahoo
 
Mejoras del colegio
Mejoras del colegio
Kellis Gonzalez
 
april
april
Nikhil Chabra
 
powerpoint nota dinas
powerpoint nota dinas
Imas Fera
 
Question 5
Question 5
katiehatton123
 
Step by step of my music magazine contents
Step by step of my music magazine contents
katiehatton123
 
Codes and conventions of kerrang’s
Codes and conventions of kerrang’s
katiehatton123
 
PPT Kewirausahaan Kepererawatan Baby spa health center
PPT Kewirausahaan Kepererawatan Baby spa health center
Politeknik Kesehatan Kementerian Kesehatan Malang
 
Codes and conventions of a contents page
Codes and conventions of a contents page
baileyharland
 
ajeet kumar Delhi 12+ yrs (3+ AS AN HR RECRUITER)
ajeet kumar Delhi 12+ yrs (3+ AS AN HR RECRUITER)
Ajeet Kumar198282
 
Resume_Networking_profile__Harish_New_CV
Resume_Networking_profile__Harish_New_CV
Harish Raghav
 
Broad bean diseases A Lecture By Allah Dad Khan Provincial Coordinator IPM MI...
Broad bean diseases A Lecture By Allah Dad Khan Provincial Coordinator IPM MI...
Mr.Allah Dad Khan
 
Ordnance School Diploma
Ordnance School Diploma
Antoine Ngemhe
 
powerpoint nota dinas
powerpoint nota dinas
Imas Fera
 
Step by step of my music magazine contents
Step by step of my music magazine contents
katiehatton123
 
Codes and conventions of kerrang’s
Codes and conventions of kerrang’s
katiehatton123
 
Ad

Similar to Data Visualization With R: Learn To Modify Color Of Plots (20)

Data Visualization With R
Data Visualization With R
Rsquared Academy
 
Exploratory data analysis using r
Exploratory data analysis using r
Tahera Shaikh
 
Presentation: Plotting Systems in R
Presentation: Plotting Systems in R
Ilya Zhbannikov
 
Chart and graphs in R programming language
Chart and graphs in R programming language
CHANDAN KUMAR
 
Data visualization using the grammar of graphics
Data visualization using the grammar of graphics
Rupak Roy
 
Tech talk ggplot2
Tech talk ggplot2
jalle6
 
Introduction to R Short course Fall 2016
Introduction to R Short course Fall 2016
Spencer Fox
 
Introduction to GGVIS Visualization
Introduction to GGVIS Visualization
HemantSingh311
 
DA_THEORY_PPT DA_THEORY_PPT DA_THEORY_PPT
DA_THEORY_PPT DA_THEORY_PPT DA_THEORY_PPT
20harish08
 
Tools for research plotting
Tools for research plotting
Nimrita Koul
 
Dplyr v2 . Exploratory data analysis.pdf
Dplyr v2 . Exploratory data analysis.pdf
PrinceUzair4
 
Dplyr v2 . Exploratory data analysis.pdf
Dplyr v2 . Exploratory data analysis.pdf
PrinceUzair4
 
VISIALIZACION DE DATA.pdf
VISIALIZACION DE DATA.pdf
Ivan Bautista Fuentes
 
Data visualization-2.1
Data visualization-2.1
RenukaRajmohan
 
R workshop iii -- 3 hours to learn ggplot2 series
R workshop iii -- 3 hours to learn ggplot2 series
Vivian S. Zhang
 
Data Visualization with ggplot2.pdf
Data Visualization with ggplot2.pdf
CarlosTrujillo199971
 
Data Visualization using matplotlib
Data Visualization using matplotlib
Bruno Gonçalves
 
UNIT_4_data visualization.pptx
UNIT_4_data visualization.pptx
BhagyasriPatel2
 
Data visualization using R
Data visualization using R
Ummiya Mohammedi
 
R and Visualization: A match made in Heaven
R and Visualization: A match made in Heaven
Edureka!
 
Exploratory data analysis using r
Exploratory data analysis using r
Tahera Shaikh
 
Presentation: Plotting Systems in R
Presentation: Plotting Systems in R
Ilya Zhbannikov
 
Chart and graphs in R programming language
Chart and graphs in R programming language
CHANDAN KUMAR
 
Data visualization using the grammar of graphics
Data visualization using the grammar of graphics
Rupak Roy
 
Tech talk ggplot2
Tech talk ggplot2
jalle6
 
Introduction to R Short course Fall 2016
Introduction to R Short course Fall 2016
Spencer Fox
 
Introduction to GGVIS Visualization
Introduction to GGVIS Visualization
HemantSingh311
 
DA_THEORY_PPT DA_THEORY_PPT DA_THEORY_PPT
DA_THEORY_PPT DA_THEORY_PPT DA_THEORY_PPT
20harish08
 
Tools for research plotting
Tools for research plotting
Nimrita Koul
 
Dplyr v2 . Exploratory data analysis.pdf
Dplyr v2 . Exploratory data analysis.pdf
PrinceUzair4
 
Dplyr v2 . Exploratory data analysis.pdf
Dplyr v2 . Exploratory data analysis.pdf
PrinceUzair4
 
Data visualization-2.1
Data visualization-2.1
RenukaRajmohan
 
R workshop iii -- 3 hours to learn ggplot2 series
R workshop iii -- 3 hours to learn ggplot2 series
Vivian S. Zhang
 
Data Visualization with ggplot2.pdf
Data Visualization with ggplot2.pdf
CarlosTrujillo199971
 
Data Visualization using matplotlib
Data Visualization using matplotlib
Bruno Gonçalves
 
UNIT_4_data visualization.pptx
UNIT_4_data visualization.pptx
BhagyasriPatel2
 
Data visualization using R
Data visualization using R
Ummiya Mohammedi
 
R and Visualization: A match made in Heaven
R and Visualization: A match made in Heaven
Edureka!
 
Ad

More from Rsquared Academy (20)

Handling Date & Time in R
Handling Date & Time in R
Rsquared Academy
 
Market Basket Analysis in R
Market Basket Analysis in R
Rsquared Academy
 
Practical Introduction to Web scraping using R
Practical Introduction to Web scraping using R
Rsquared Academy
 
Joining Data with dplyr
Joining Data with dplyr
Rsquared Academy
 
Explore Data using dplyr
Explore Data using dplyr
Rsquared Academy
 
Data Wrangling with dplyr
Data Wrangling with dplyr
Rsquared Academy
 
Writing Readable Code with Pipes
Writing Readable Code with Pipes
Rsquared Academy
 
Introduction to tibbles
Introduction to tibbles
Rsquared Academy
 
Read data from Excel spreadsheets into R
Read data from Excel spreadsheets into R
Rsquared Academy
 
Read/Import data from flat/delimited files into R
Read/Import data from flat/delimited files into R
Rsquared Academy
 
Variables & Data Types in R
Variables & Data Types in R
Rsquared Academy
 
How to install & update R packages?
How to install & update R packages?
Rsquared Academy
 
How to get help in R?
How to get help in R?
Rsquared Academy
 
Introduction to R
Introduction to R
Rsquared Academy
 
RMySQL Tutorial For Beginners
RMySQL Tutorial For Beginners
Rsquared Academy
 
R Markdown Tutorial For Beginners
R Markdown Tutorial For Beginners
Rsquared Academy
 
R Programming: Introduction to Matrices
R Programming: Introduction to Matrices
Rsquared Academy
 
R Programming: Introduction to Vectors
R Programming: Introduction to Vectors
Rsquared Academy
 
R Programming: Variables & Data Types
R Programming: Variables & Data Types
Rsquared Academy
 
R Programming: Mathematical Functions In R
R Programming: Mathematical Functions In R
Rsquared Academy
 
Market Basket Analysis in R
Market Basket Analysis in R
Rsquared Academy
 
Practical Introduction to Web scraping using R
Practical Introduction to Web scraping using R
Rsquared Academy
 
Writing Readable Code with Pipes
Writing Readable Code with Pipes
Rsquared Academy
 
Read data from Excel spreadsheets into R
Read data from Excel spreadsheets into R
Rsquared Academy
 
Read/Import data from flat/delimited files into R
Read/Import data from flat/delimited files into R
Rsquared Academy
 
Variables & Data Types in R
Variables & Data Types in R
Rsquared Academy
 
How to install & update R packages?
How to install & update R packages?
Rsquared Academy
 
RMySQL Tutorial For Beginners
RMySQL Tutorial For Beginners
Rsquared Academy
 
R Markdown Tutorial For Beginners
R Markdown Tutorial For Beginners
Rsquared Academy
 
R Programming: Introduction to Matrices
R Programming: Introduction to Matrices
Rsquared Academy
 
R Programming: Introduction to Vectors
R Programming: Introduction to Vectors
Rsquared Academy
 
R Programming: Variables & Data Types
R Programming: Variables & Data Types
Rsquared Academy
 
R Programming: Mathematical Functions In R
R Programming: Mathematical Functions In R
Rsquared Academy
 

Recently uploaded (20)

PPT1_CB_VII_CS_Ch3_FunctionsandChartsinCalc.ppsx
PPT1_CB_VII_CS_Ch3_FunctionsandChartsinCalc.ppsx
animaroy81
 
PPT2 W1L2.pptx.........................................
PPT2 W1L2.pptx.........................................
palicteronalyn26
 
25 items quiz for practical research 1 in grade 11
25 items quiz for practical research 1 in grade 11
leamaydayaganon81
 
Crafting-Research-Recommendations Grade 12.pptx
Crafting-Research-Recommendations Grade 12.pptx
DaryllWhere
 
ilide.info-tg-understanding-culture-society-and-politics-pr_127f984d2904c57ec...
ilide.info-tg-understanding-culture-society-and-politics-pr_127f984d2904c57ec...
jed P
 
Microsoft Power BI - Advanced Certificate for Business Intelligence using Pow...
Microsoft Power BI - Advanced Certificate for Business Intelligence using Pow...
Prasenjit Debnath
 
Measurecamp Copenhagen - Consent Context
Measurecamp Copenhagen - Consent Context
Human37
 
All the DataOps, all the paradigms .
All the DataOps, all the paradigms .
Lars Albertsson
 
Communication_Skills_Class10_Visual.pptx
Communication_Skills_Class10_Visual.pptx
namanrastogi70555
 
Indigo_Airlines_Strategy_Presentation.pptx
Indigo_Airlines_Strategy_Presentation.pptx
mukeshpurohit991
 
Flextronics Employee Safety Data-Project-2.pptx
Flextronics Employee Safety Data-Project-2.pptx
kilarihemadri
 
presentation4.pdf Intro to mcmc methodss
presentation4.pdf Intro to mcmc methodss
SergeyTsygankov6
 
Daily, Weekly, Monthly Report MTC March 2025.pptx
Daily, Weekly, Monthly Report MTC March 2025.pptx
PanjiDewaPamungkas1
 
最新版美国威斯康星大学河城分校毕业证(UWRF毕业证书)原版定制
最新版美国威斯康星大学河城分校毕业证(UWRF毕业证书)原版定制
taqyea
 
@Reset-Password.pptx presentakh;kenvtion
@Reset-Password.pptx presentakh;kenvtion
MarkLariosa1
 
Data Visualisation in data science for students
Data Visualisation in data science for students
confidenceascend
 
Starbucks in the Indian market through its joint venture.
Starbucks in the Indian market through its joint venture.
sales480687
 
11_L2_Defects_and_Trouble_Shooting_2014[1].pdf
11_L2_Defects_and_Trouble_Shooting_2014[1].pdf
gun3awan88
 
Predicting Titanic Survival Presentation
Predicting Titanic Survival Presentation
praxyfarhana
 
lecture12.pdf Introduction to bioinformatics
lecture12.pdf Introduction to bioinformatics
SergeyTsygankov6
 
PPT1_CB_VII_CS_Ch3_FunctionsandChartsinCalc.ppsx
PPT1_CB_VII_CS_Ch3_FunctionsandChartsinCalc.ppsx
animaroy81
 
PPT2 W1L2.pptx.........................................
PPT2 W1L2.pptx.........................................
palicteronalyn26
 
25 items quiz for practical research 1 in grade 11
25 items quiz for practical research 1 in grade 11
leamaydayaganon81
 
Crafting-Research-Recommendations Grade 12.pptx
Crafting-Research-Recommendations Grade 12.pptx
DaryllWhere
 
ilide.info-tg-understanding-culture-society-and-politics-pr_127f984d2904c57ec...
ilide.info-tg-understanding-culture-society-and-politics-pr_127f984d2904c57ec...
jed P
 
Microsoft Power BI - Advanced Certificate for Business Intelligence using Pow...
Microsoft Power BI - Advanced Certificate for Business Intelligence using Pow...
Prasenjit Debnath
 
Measurecamp Copenhagen - Consent Context
Measurecamp Copenhagen - Consent Context
Human37
 
All the DataOps, all the paradigms .
All the DataOps, all the paradigms .
Lars Albertsson
 
Communication_Skills_Class10_Visual.pptx
Communication_Skills_Class10_Visual.pptx
namanrastogi70555
 
Indigo_Airlines_Strategy_Presentation.pptx
Indigo_Airlines_Strategy_Presentation.pptx
mukeshpurohit991
 
Flextronics Employee Safety Data-Project-2.pptx
Flextronics Employee Safety Data-Project-2.pptx
kilarihemadri
 
presentation4.pdf Intro to mcmc methodss
presentation4.pdf Intro to mcmc methodss
SergeyTsygankov6
 
Daily, Weekly, Monthly Report MTC March 2025.pptx
Daily, Weekly, Monthly Report MTC March 2025.pptx
PanjiDewaPamungkas1
 
最新版美国威斯康星大学河城分校毕业证(UWRF毕业证书)原版定制
最新版美国威斯康星大学河城分校毕业证(UWRF毕业证书)原版定制
taqyea
 
@Reset-Password.pptx presentakh;kenvtion
@Reset-Password.pptx presentakh;kenvtion
MarkLariosa1
 
Data Visualisation in data science for students
Data Visualisation in data science for students
confidenceascend
 
Starbucks in the Indian market through its joint venture.
Starbucks in the Indian market through its joint venture.
sales480687
 
11_L2_Defects_and_Trouble_Shooting_2014[1].pdf
11_L2_Defects_and_Trouble_Shooting_2014[1].pdf
gun3awan88
 
Predicting Titanic Survival Presentation
Predicting Titanic Survival Presentation
praxyfarhana
 
lecture12.pdf Introduction to bioinformatics
lecture12.pdf Introduction to bioinformatics
SergeyTsygankov6
 

Data Visualization With R: Learn To Modify Color Of Plots

  • 1. www.r-squared.in/git-hub dataCrunch Data Visualization With R Learn To Add/Modify Color To Plots
  • 2. dataCrunchCourse Material Slide 2 All the material related to this course are available at our Website Slides can be viewed at SlideShare Scripts can be downloaded from GitHub Videos can be viewed on our Youtube Channel
  • 4. dataCrunchColor Slide 4 In this section, we will learn to add colors to the following using the col argument: ● Plot Symbol ● Title & Subtitle ● Axis ● Axis Labels ● Foreground
  • 5. dataCrunchSyntax Slide 5 Feature Argument Value Example Symbol col String Hexadecimal RGB "blue" Title col.main "#0000ff" Subtitle col.sub rgb(0, 0, 1) Axis col.axis "red" Label col.lab "#ff0000" Foreground fg rgb(1, 0, 0) The col argument can be used along with main, sub, axis and lab arguments to specify the color of the title, subtitle, axes and the labels.
  • 6. dataCrunchColor: Symbol Slide 6 # modify color of the plot plot(mtcars$disp, mtcars$mpg, col= "red") OR plot(mtcars$disp, mtcars$mpg, col = "#ff0000") OR plot(mtcars$disp, mtcars$mpg, col = rgb(1, 0, 0)) Description Let us begin by adding color to the symbol in the plot using the col argument in the plot() function. Code
  • 7. dataCrunchColor: Title Slide 7 # modify the color of the title plot(mtcars$disp, mtcars$mpg, main = "Displacement vs Miles Per Gallon", col.main = "blue") OR plot(mtcars$disp, mtcars$mpg, main = "Displacement vs Miles Per Gallon", col.main = "#0000ff") OR plot(mtcars$disp, mtcars$mpg, main = "Displacement vs Miles Per Gallon", col.main = rgb(0, 0, 1)) Description The color of the title can be modified by using the col.main argument in the plot() function. Code
  • 8. dataCrunchColor: Subtitle Slide 8 # modify the color of the subtitle plot(mtcars$disp, mtcars$mpg, sub= "Displacement vs Miles Per Gallon", col.sub = "blue") OR plot(mtcars$disp, mtcars$mpg, sub= "Displacement vs Miles Per Gallon", col.sub = "#0000ff") OR plot(mtcars$disp, mtcars$mpg, sub= "Displacement vs Miles Per Gallon", col.sub = rgb(0, 0, 1)) Description The color of the subtitle can be modified by using the col.sub argument in the plot() function. Code
  • 9. dataCrunchColor: Axis Slide 9 # modify the color of the axis plot(mtcars$disp, mtcars$mpg, col.axis = "blue") OR plot(mtcars$disp, mtcars$mpg, col.axis = "#0000ff") OR plot(mtcars$disp, mtcars$mpg, col.axis = rgb(0, 0, 1)) Description The color of the axis can be modified by using the col.axis argument in the plot() function. Code
  • 10. dataCrunchColor: Labels Slide 10 # modify the color of the labels plot(mtcars$disp, mtcars$mpg, xlab = "Displacement", ylab = "Miles Per Gallon", col.lab = "blue") Description The color of the labels can be modified by using the col.lab argument in the plot() function. Code
  • 11. dataCrunchColor: Foreground Slide 11 # modify the color of the foreground plot(mtcars$disp, mtcars$mpg, fg= "red") Description The color of the foreground can be modified by using the fg argument in the plot() function. Code
  • 12. dataCrunchColor: Using title() function Slide 12 # Create a basic plot plot(mtcars$disp, mtcars$mpg, ann= FALSE) # modify color using title() function title(main = "Displacement vs Miles Per Gallon", xlab = "Displacement", ylab = "Miles Per Gallon", col.main = "blue", col.lab = "red") Description The colors of the title, subtitle and the labels can be modified using the title() function as well. Let us try it out: Code
  • 13. dataCrunch Slide 13 Visit dataCrunch for tutorials on: → R Programming → Business Analytics → Data Visualization → Web Applications → Package Development → Git & GitHub