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

More Related Content

What's hot (19)

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

Viewers also liked (14)

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

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

DOCX
Data visualization with R and ggplot2.docx
kassaye4
 
PDF
Data Visualization With R
Rsquared Academy
 
PPTX
Artificial inteliggence and machine learning ppt
PromashreeChakrabort1
 
PPT
CS 354 Pixel Updating
Mark Kilgard
 
PPTX
Computation Assignment Help
Programming Homework Help
 
PPTX
CIV1900 Matlab - Plotting & Coursework
TUOS-Sam
 
PDF
Q plot tutorial
Abhik Seal
 
PPTX
Exploratory data analysis using r
Tahera Shaikh
 
PDF
R Markdown Reference Guide for reproducible research
danxexcel
 
PDF
The Ring programming language version 1.3 book - Part 38 of 88
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.3 book - Part 48 of 184
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.3 book - Part 58 of 184
Mahmoud Samir Fayed
 
PPTX
R and Visualization: A match made in Heaven
Edureka!
 
PPTX
Murtaugh 2022 Appl Comp Genomics Tidyverse lecture.pptx-1.pptx
oliversen
 
PDF
Data visualization using the grammar of graphics
Rupak Roy
 
PPTX
2GKS, Open GL and IGES_Video Lect Given by Renjin.pptx
RamanathanSabesan
 
PDF
2nd Semester M Tech: Computer Science and Engineering (Jun-2016) Question Pa...
BGS Institute of Technology, Adichunchanagiri University (ACU)
 
PPTX
Unit3-v1-Plotting and Visualization.pptx
yerrasaniayyapparedd
 
PDF
The 2nd graph database in sv meetup
Joshua Bae
 
PPTX
Basic Analysis using Python
Sankhya_Analytics
 
Data visualization with R and ggplot2.docx
kassaye4
 
Data Visualization With R
Rsquared Academy
 
Artificial inteliggence and machine learning ppt
PromashreeChakrabort1
 
CS 354 Pixel Updating
Mark Kilgard
 
Computation Assignment Help
Programming Homework Help
 
CIV1900 Matlab - Plotting & Coursework
TUOS-Sam
 
Q plot tutorial
Abhik Seal
 
Exploratory data analysis using r
Tahera Shaikh
 
R Markdown Reference Guide for reproducible research
danxexcel
 
The Ring programming language version 1.3 book - Part 38 of 88
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.3 book - Part 48 of 184
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.3 book - Part 58 of 184
Mahmoud Samir Fayed
 
R and Visualization: A match made in Heaven
Edureka!
 
Murtaugh 2022 Appl Comp Genomics Tidyverse lecture.pptx-1.pptx
oliversen
 
Data visualization using the grammar of graphics
Rupak Roy
 
2GKS, Open GL and IGES_Video Lect Given by Renjin.pptx
RamanathanSabesan
 
2nd Semester M Tech: Computer Science and Engineering (Jun-2016) Question Pa...
BGS Institute of Technology, Adichunchanagiri University (ACU)
 
Unit3-v1-Plotting and Visualization.pptx
yerrasaniayyapparedd
 
The 2nd graph database in sv meetup
Joshua Bae
 
Basic Analysis using Python
Sankhya_Analytics
 
Ad

More from Rsquared Academy (20)

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

Recently uploaded (20)

PPT
tuberculosiship-2106031cyyfuftufufufivifviviv
AkshaiRam
 
PDF
A GraphRAG approach for Energy Efficiency Q&A
Marco Brambilla
 
PDF
Development and validation of the Japanese version of the Organizational Matt...
Yoga Tokuyoshi
 
PDF
apidays Singapore 2025 - From API Intelligence to API Governance by Harsha Ch...
apidays
 
PPTX
thid ppt defines the ich guridlens and gives the information about the ICH gu...
shaistabegum14
 
PDF
1750162332_Snapshot-of-Indias-oil-Gas-data-May-2025.pdf
sandeep718278
 
PPTX
apidays Helsinki & North 2025 - Agentic AI: A Friend or Foe?, Merja Kajava (A...
apidays
 
PPTX
apidays Singapore 2025 - Designing for Change, Julie Schiller (Google)
apidays
 
PPTX
apidays Helsinki & North 2025 - Running a Successful API Program: Best Practi...
apidays
 
PDF
Data Science Course Certificate by Sigma Software University
Stepan Kalika
 
PDF
The Best NVIDIA GPUs for LLM Inference in 2025.pdf
Tamanna36
 
PPTX
apidays Helsinki & North 2025 - From Chaos to Clarity: Designing (AI-Ready) A...
apidays
 
PPTX
04_Tamás Marton_Intuitech .pptx_AI_Barometer_2025
FinTech Belgium
 
PDF
Driving Employee Engagement in a Hybrid World.pdf
Mia scott
 
PPTX
BinarySearchTree in datastructures in detail
kichokuttu
 
PPTX
apidays Helsinki & North 2025 - API access control strategies beyond JWT bear...
apidays
 
PDF
Optimizing Large Language Models with vLLM and Related Tools.pdf
Tamanna36
 
PDF
Business implication of Artificial Intelligence.pdf
VishalChugh12
 
PPTX
Powerful Uses of Data Analytics You Should Know
subhashenia
 
PDF
apidays Singapore 2025 - Trustworthy Generative AI: The Role of Observability...
apidays
 
tuberculosiship-2106031cyyfuftufufufivifviviv
AkshaiRam
 
A GraphRAG approach for Energy Efficiency Q&A
Marco Brambilla
 
Development and validation of the Japanese version of the Organizational Matt...
Yoga Tokuyoshi
 
apidays Singapore 2025 - From API Intelligence to API Governance by Harsha Ch...
apidays
 
thid ppt defines the ich guridlens and gives the information about the ICH gu...
shaistabegum14
 
1750162332_Snapshot-of-Indias-oil-Gas-data-May-2025.pdf
sandeep718278
 
apidays Helsinki & North 2025 - Agentic AI: A Friend or Foe?, Merja Kajava (A...
apidays
 
apidays Singapore 2025 - Designing for Change, Julie Schiller (Google)
apidays
 
apidays Helsinki & North 2025 - Running a Successful API Program: Best Practi...
apidays
 
Data Science Course Certificate by Sigma Software University
Stepan Kalika
 
The Best NVIDIA GPUs for LLM Inference in 2025.pdf
Tamanna36
 
apidays Helsinki & North 2025 - From Chaos to Clarity: Designing (AI-Ready) A...
apidays
 
04_Tamás Marton_Intuitech .pptx_AI_Barometer_2025
FinTech Belgium
 
Driving Employee Engagement in a Hybrid World.pdf
Mia scott
 
BinarySearchTree in datastructures in detail
kichokuttu
 
apidays Helsinki & North 2025 - API access control strategies beyond JWT bear...
apidays
 
Optimizing Large Language Models with vLLM and Related Tools.pdf
Tamanna36
 
Business implication of Artificial Intelligence.pdf
VishalChugh12
 
Powerful Uses of Data Analytics You Should Know
subhashenia
 
apidays Singapore 2025 - Trustworthy Generative AI: The Role of Observability...
apidays
 

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