SlideShare a Scribd company logo
www.r-squared.in/git-hub
dataCrunch Data Visualization With R
Learn To Modify Title, Axis Labels & Range
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
Title, Axis Labels & Range
Slide 3
dataCrunchTitle & Labels
Slide 4
In this section, we will learn to enhance the plot by adding/modifying the following features:
● Title
● Subtitle
● Axis Labels
● Axis Range
dataCrunchIntroduction
Slide 5
In the previous section, we created plots which did not have any title or labels. A new user of a plot
should know what the X and Y axis represent as well as the primary information being communicated
by the plot. The title, axis labels and range play an important role in making the plot holistic.
There are two ways of adding the above mentioned elements to a plot:
● Use the relevant arguments within the plot() function.
● Use the title() function.
We will explore both the methods one by one and you can choose the method that you find most
convenient. Let us begin by adding the features using the plot() function.
dataCrunchSyntax
Slide 6
Feature Argument Value Example
Title main String “Scatter Plot”
Subtitle sub String “Displacement vs Miles Per Gallon”
X Axis Label xlab String “Displacement”
Y Axis Label ylab String “Miles Per Gallon”
X Axis Range xlim Numeric Vector c(0, 500)
Y Axis Range ylim Numeric Vector c(0, 50)
dataCrunchTitle
Slide 7
# create a basic plot and add a title
plot(mtcars$disp, mtcars$mpg,
main = “Displacement vs Miles Per Gallon”)
Description
Use the main argument in the plot()
function to add a title to the plot. The title
must be enclosed in double quotes as it is a
string.
Code
dataCrunchSubtitle
Slide 8
# create a basic plot and add a subtitle
plot(mtcars$disp, mtcars$mpg,
sub = “Displacement vs Miles Per Gallon”)
Description
Use the sub argument in the plot()
function to add a subtitle to the plot. The
subtitle must be enclosed in double quotes
as it is a string.
Code
dataCrunchAxis Labels
Slide 9
# create a basic plot and add axis labels
plot(mtcars$disp, mtcars$mpg,
xlab = "Displacement",
ylab = "Miles Per Gallon")
Description
In all plots created till now, the axis labels
appear as mtcars$disp and mtcars$mpg.
It is not the most elegant way of labeling the
axis and it would make more sense to use
appropriate names. Use the xlab and ylab
arguments in the plot() function to add the
X and Y axis labels.
Code
dataCrunchAxis Range
Slide 10
# create a basic plot and modify axis range
plot(mtcars$disp, mtcars$mpg,
xlim = c(0, 600),
ylim = c(0, 50))
Description
The range of the axis can be modified using
the xlim and ylim arguments in the
plot() function. The lower and upper limit
for both the axis must be mentioned in a
numeric vector.
Code
dataCrunchSo far...
Slide 11
# create a plot with title, subtitle, axis
labels and range
plot(mtcars$disp, mtcars$mpg,
main = "Displacement vs Miles Per Gallon",
sub = "Scatter Plot",
xlab = "Displacement",
ylab = "Miles Per Gallon",
xlim = c(0, 600), ylim = c(0, 50))
Description
Let us create a plot that has all the features
that we have learnt so far:
Code
dataCrunchtitle() Function
Slide 12
# create a basic plot
plot(mtcars$disp, mtcars$mpg)
# add title and label using title() function
title(main = "Displacement vs Miles Per Gallon",
sub = "Scatter Plot",
xlab = "Displacement",
ylab = "Miles Per Gallon")
Description
We will add/modify the same set of features but
using the title() function instead of the
arguments in the plot() function but we will
continue to use the plot() function for creating the
basic plot.
Code
Oops.. We have a problem. If you have observed
carefully, the title() function has overwritten the
default axis labels created by the plot() function.
dataCrunchtitle() Function
Slide 13
# create a basic plot
plot(mtcars$disp, mtcars$mpg, ann = FALSE)
# add title and label using title() function
title(main = "Displacement vs Miles Per Gallon",
sub = "Scatter Plot",
xlab = "Displacement",
ylab = "Miles Per Gallon")
Description
Use the ann argument in the plot() function and
set it to FALSE to ensure that the plot() function
does not add the default labels.
Code
Note: The range of the axis cannot be modified
using the title() function.
dataCrunch
Slide 14
Visit dataCrunch for
tutorials on:
→ R Programming
→ Business Analytics
→ Data Visualization
→ Web Applications
→ Package Development
→ Git & GitHub

More Related Content

PDF
Data Visualization With R
PDF
Data Visualization With R: Learn To Combine Multiple Graphs
PDF
Data Visualization With R: Learn To Modify Color Of Plots
PDF
Data Visualization With R: Introduction
PDF
R Data Visualization Tutorial: Bar Plots
PDF
Data Visualization With R: Learn To Modify Font Of Graphical Parameters
PDF
R Data Visualization: Learn To Add Text Annotations To Plots
PDF
R Programming: Numeric Functions In R
Data Visualization With R
Data Visualization With R: Learn To Combine Multiple Graphs
Data Visualization With R: Learn To Modify Color Of Plots
Data Visualization With R: Introduction
R Data Visualization Tutorial: Bar Plots
Data Visualization With R: Learn To Modify Font Of Graphical Parameters
R Data Visualization: Learn To Add Text Annotations To Plots
R Programming: Numeric Functions In R

What's hot (17)

PDF
R Programming: Introduction to Vectors
PPT
R studio
PPTX
A quick introduction to R
PDF
NCCU: Statistics in the Criminal Justice System, R basics and Simulation - Pr...
PPTX
Stack - Data Structure
PDF
GNU octave
PDF
PPTX
Basic of octave matlab programming language
PPTX
Graph Plots in Matlab
PPTX
Matlab Visualizing Data
PPTX
Stack and queue
PPTX
Queue Implementation Using Array & Linked List
PDF
Hive function-cheat-sheet
PDF
Doc 20180130-wa0004
PPTX
Data structures
PPTX
2 d array(part 1) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
R Programming: Introduction to Vectors
R studio
A quick introduction to R
NCCU: Statistics in the Criminal Justice System, R basics and Simulation - Pr...
Stack - Data Structure
GNU octave
Basic of octave matlab programming language
Graph Plots in Matlab
Matlab Visualizing Data
Stack and queue
Queue Implementation Using Array & Linked List
Hive function-cheat-sheet
Doc 20180130-wa0004
Data structures
2 d array(part 1) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
Ad

Similar to Data Visualization With R: Learn To Modify Title, Axis Labels & Range (20)

PPTX
Exploratory data analysis using r
DOCX
Data visualization with R and ggplot2.docx
PDF
Dplyr v2 . Exploratory data analysis.pdf
PDF
Dplyr v2 . Exploratory data analysis.pdf
PPTX
Introduction to GGVIS Visualization
PDF
Unit---4.pdf how to gst du paper in this day and age
PDF
M4_DAR_part1. module part 4 analystics with r
PPTX
UNIT_4_data visualization.pptx
PPTX
Chart and graphs in R programming language
PPTX
4.Data-Visualization.pptx
PPT
Tools for research plotting
PDF
Presentation: Plotting Systems in R
PPT
Tools for research plotting
PPTX
Lab 2 - Managing Data in R Basic Conecpt.pptx
PPTX
a9bf73_Introduction to Matplotlib01.pptx
PDF
R training5
PPTX
Murtaugh 2022 Appl Comp Genomics Tidyverse lecture.pptx-1.pptx
PDF
R visualization: ggplot2, googlevis, plotly, igraph Overview
DOCX
Concept mapping patient initials, age, gender and admitting d
PDF
[系列活動] Data exploration with modern R
Exploratory data analysis using r
Data visualization with R and ggplot2.docx
Dplyr v2 . Exploratory data analysis.pdf
Dplyr v2 . Exploratory data analysis.pdf
Introduction to GGVIS Visualization
Unit---4.pdf how to gst du paper in this day and age
M4_DAR_part1. module part 4 analystics with r
UNIT_4_data visualization.pptx
Chart and graphs in R programming language
4.Data-Visualization.pptx
Tools for research plotting
Presentation: Plotting Systems in R
Tools for research plotting
Lab 2 - Managing Data in R Basic Conecpt.pptx
a9bf73_Introduction to Matplotlib01.pptx
R training5
Murtaugh 2022 Appl Comp Genomics Tidyverse lecture.pptx-1.pptx
R visualization: ggplot2, googlevis, plotly, igraph Overview
Concept mapping patient initials, age, gender and admitting d
[系列活動] Data exploration with modern R
Ad

More from Rsquared Academy (20)

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

Recently uploaded (20)

PPTX
iec ppt-1 pptx icmr ppt on rehabilitation.pptx
PDF
168300704-gasification-ppt.pdfhghhhsjsjhsuxush
PDF
Fluorescence-microscope_Botany_detailed content
PPTX
05. PRACTICAL GUIDE TO MICROSOFT EXCEL.pptx
PPTX
advance b rammar.pptxfdgdfgdfsgdfgsdgfdfgdfgsdfgdfgdfg
PDF
Mega Projects Data Mega Projects Data
PPTX
Introduction-to-Cloud-ComputingFinal.pptx
PPT
Chapter 3 METAL JOINING.pptnnnnnnnnnnnnn
PDF
BF and FI - Blockchain, fintech and Financial Innovation Lesson 2.pdf
PPTX
ALIMENTARY AND BILIARY CONDITIONS 3-1.pptx
PDF
22.Patil - Early prediction of Alzheimer’s disease using convolutional neural...
PPTX
Introduction to Knowledge Engineering Part 1
PPTX
Moving the Public Sector (Government) to a Digital Adoption
PPTX
Introduction to Basics of Ethical Hacking and Penetration Testing -Unit No. 1...
PPTX
STUDY DESIGN details- Lt Col Maksud (21).pptx
PPTX
Supervised vs unsupervised machine learning algorithms
PPTX
Data_Analytics_and_PowerBI_Presentation.pptx
PPTX
oil_refinery_comprehensive_20250804084928 (1).pptx
PPTX
Business Acumen Training GuidePresentation.pptx
PPT
Quality review (1)_presentation of this 21
iec ppt-1 pptx icmr ppt on rehabilitation.pptx
168300704-gasification-ppt.pdfhghhhsjsjhsuxush
Fluorescence-microscope_Botany_detailed content
05. PRACTICAL GUIDE TO MICROSOFT EXCEL.pptx
advance b rammar.pptxfdgdfgdfsgdfgsdgfdfgdfgsdfgdfgdfg
Mega Projects Data Mega Projects Data
Introduction-to-Cloud-ComputingFinal.pptx
Chapter 3 METAL JOINING.pptnnnnnnnnnnnnn
BF and FI - Blockchain, fintech and Financial Innovation Lesson 2.pdf
ALIMENTARY AND BILIARY CONDITIONS 3-1.pptx
22.Patil - Early prediction of Alzheimer’s disease using convolutional neural...
Introduction to Knowledge Engineering Part 1
Moving the Public Sector (Government) to a Digital Adoption
Introduction to Basics of Ethical Hacking and Penetration Testing -Unit No. 1...
STUDY DESIGN details- Lt Col Maksud (21).pptx
Supervised vs unsupervised machine learning algorithms
Data_Analytics_and_PowerBI_Presentation.pptx
oil_refinery_comprehensive_20250804084928 (1).pptx
Business Acumen Training GuidePresentation.pptx
Quality review (1)_presentation of this 21

Data Visualization With R: Learn To Modify Title, Axis Labels & Range

  • 1. www.r-squared.in/git-hub dataCrunch Data Visualization With R Learn To Modify Title, Axis Labels & Range
  • 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. dataCrunchTitle & Labels Slide 4 In this section, we will learn to enhance the plot by adding/modifying the following features: ● Title ● Subtitle ● Axis Labels ● Axis Range
  • 5. dataCrunchIntroduction Slide 5 In the previous section, we created plots which did not have any title or labels. A new user of a plot should know what the X and Y axis represent as well as the primary information being communicated by the plot. The title, axis labels and range play an important role in making the plot holistic. There are two ways of adding the above mentioned elements to a plot: ● Use the relevant arguments within the plot() function. ● Use the title() function. We will explore both the methods one by one and you can choose the method that you find most convenient. Let us begin by adding the features using the plot() function.
  • 6. dataCrunchSyntax Slide 6 Feature Argument Value Example Title main String “Scatter Plot” Subtitle sub String “Displacement vs Miles Per Gallon” X Axis Label xlab String “Displacement” Y Axis Label ylab String “Miles Per Gallon” X Axis Range xlim Numeric Vector c(0, 500) Y Axis Range ylim Numeric Vector c(0, 50)
  • 7. dataCrunchTitle Slide 7 # create a basic plot and add a title plot(mtcars$disp, mtcars$mpg, main = “Displacement vs Miles Per Gallon”) Description Use the main argument in the plot() function to add a title to the plot. The title must be enclosed in double quotes as it is a string. Code
  • 8. dataCrunchSubtitle Slide 8 # create a basic plot and add a subtitle plot(mtcars$disp, mtcars$mpg, sub = “Displacement vs Miles Per Gallon”) Description Use the sub argument in the plot() function to add a subtitle to the plot. The subtitle must be enclosed in double quotes as it is a string. Code
  • 9. dataCrunchAxis Labels Slide 9 # create a basic plot and add axis labels plot(mtcars$disp, mtcars$mpg, xlab = "Displacement", ylab = "Miles Per Gallon") Description In all plots created till now, the axis labels appear as mtcars$disp and mtcars$mpg. It is not the most elegant way of labeling the axis and it would make more sense to use appropriate names. Use the xlab and ylab arguments in the plot() function to add the X and Y axis labels. Code
  • 10. dataCrunchAxis Range Slide 10 # create a basic plot and modify axis range plot(mtcars$disp, mtcars$mpg, xlim = c(0, 600), ylim = c(0, 50)) Description The range of the axis can be modified using the xlim and ylim arguments in the plot() function. The lower and upper limit for both the axis must be mentioned in a numeric vector. Code
  • 11. dataCrunchSo far... Slide 11 # create a plot with title, subtitle, axis labels and range plot(mtcars$disp, mtcars$mpg, main = "Displacement vs Miles Per Gallon", sub = "Scatter Plot", xlab = "Displacement", ylab = "Miles Per Gallon", xlim = c(0, 600), ylim = c(0, 50)) Description Let us create a plot that has all the features that we have learnt so far: Code
  • 12. dataCrunchtitle() Function Slide 12 # create a basic plot plot(mtcars$disp, mtcars$mpg) # add title and label using title() function title(main = "Displacement vs Miles Per Gallon", sub = "Scatter Plot", xlab = "Displacement", ylab = "Miles Per Gallon") Description We will add/modify the same set of features but using the title() function instead of the arguments in the plot() function but we will continue to use the plot() function for creating the basic plot. Code Oops.. We have a problem. If you have observed carefully, the title() function has overwritten the default axis labels created by the plot() function.
  • 13. dataCrunchtitle() Function Slide 13 # create a basic plot plot(mtcars$disp, mtcars$mpg, ann = FALSE) # add title and label using title() function title(main = "Displacement vs Miles Per Gallon", sub = "Scatter Plot", xlab = "Displacement", ylab = "Miles Per Gallon") Description Use the ann argument in the plot() function and set it to FALSE to ensure that the plot() function does not add the default labels. Code Note: The range of the axis cannot be modified using the title() function.
  • 14. dataCrunch Slide 14 Visit dataCrunch for tutorials on: → R Programming → Business Analytics → Data Visualization → Web Applications → Package Development → Git & GitHub