SlideShare una empresa de Scribd logo
1 de 24
www.r-squared.in/git-hub
dataCrunch Data Visualization With R
Learn To Add Text Annotations To Plots
dataCrunch
Text Annotations
Slide 2
dataCrunchText Annotations: Objectives
Slide 3
In this section, we will learn to:
Add text annotations to the plots using
● text() function
● mtext() function
dataCrunchText Annotations: Introduction
Slide 4
The text() and the mtext() functions allow the user to add text annotations to the plots. While the
text() function places the text inside the plot, the mtext() function places the text on the margins of
the plot.
Below is the syntax for both the functions:
# the text function
text(x, y = NULL, labels = seq_along(x), adj = NULL,
pos = NULL, offset = 0.5, vfont = NULL,
cex = 1, col = NULL, font = NULL, ...)
# the mtext function
mtext(text, side = 3, line = 0, outer = FALSE, at = NA,
adj = NA, padj = NA, cex = NA, col = NA, font = NA, ...)
Let us explore each function and its arguments one by one:
dataCrunchText Annotations: text()
Slide 5
To add text annotations using the text() function, the following 3 arguments must be supplied:
● x: x axis coordinate
● y: y axis coordinate
● text: the text to be added to the plot
Below is a simple example:
# create a basic plot
plot(mtcars$disp, mtcars$mpg)
# add text
text(340, 30, "Sample Text")
The text appears at the coordinates (340, 30) on the
plot. Ensure that the text is enclosed in double quotes
and the coordinates provided are within the range of
the X and Y axis variable.
dataCrunchtext(): Color
Slide 6
# create a basic plot
plot(mtcars$disp, mtcars$mpg)
# modify the color of the text
text(340, 30, "Sample Text", col = "red")
Description
The color of the text can be modified using the col
argument in the text() function.
Code
dataCrunchtext(): Color
Slide 7
The below plot depicts the appearance of the text when different options for col are applied:
dataCrunchtext(): Font
Slide 8
# create a basic plot
plot(mtcars$disp, mtcars$mpg)
# modify the font of the text
text(340, 30, "Sample Text", font = 2)
Description
The font of the text can be modified using the font
argument in the text() function.
Code
dataCrunchtext(): Font
Slide 9
The below plot depicts the appearance of the text when different options for font are applied:
dataCrunchtext(): Font Family
Slide 10
# create a basic plot
plot(mtcars$disp, mtcars$mpg)
# modify the font family of the text
text(340, 30, "Sample Text", family = mono)
Description
The font family of the text can be modified using the
family argument in the text() function.
Code
dataCrunchtext(): Font Family
Slide 11
The below plot depicts the appearance of the text when different options for font family are applied:
dataCrunchtext(): Font Size
Slide 12
# create a basic plot
plot(mtcars$disp, mtcars$mpg)
# modify the size of the text
text(340, 30, "Sample Text", cex = 1.5)
Description
The size of the text can be modified using the cex
argument in the text() function.
Code
dataCrunchtext(): Font Size
Slide 13
The below plot depicts the appearance of the text when different options for font size are applied:
dataCrunchmtext(): Introduction
Slide 14
The mtext() function places text annotations on the margins of the plot instead of placing them
inside the plot. It allows the user to modify the location of the text in multiple ways and we will
explore them one by one.
Below is a simple example:
# create a basic plot
plot(mtcars$disp, mtcars$mpg)
# add text
mtext("Sample Text")
As you can see, the text is placed on
the margin of the plot and not inside
the plot. Next, we will learn to
specify the margin where the text
should be placed.
dataCrunchmtext(): Margin
Slide 15
# create a basic plot
plot(mtcars$disp, mtcars$mpg)
# specify the margin on which the text should appear
mtext("Sample Text", side = 1)
Description
The margin on which we want to place the
text can be specified using the side
argument. It takes 4 values from 1-4 each
representing one side of the plot.
Code
dataCrunchmtext(): Margin Options
Slide 16
The side argument can be used to specify the margin on which the text should be placed.
side Margin
1 Bottom
2 Left
3 Top
4 Right
dataCrunchmtext(): Margin
Slide 17
The below plot depicts the appearance of the text when different options for side are applied:
dataCrunchmtext(): Line
Slide 18
# create a basic plot
plot(mtcars$disp, mtcars$mpg)
# place the text away from the margin
mtext("Sample Text", line = 1)
Description
The line argument places the text at the
specified distance from the margin. The default
value is 0 and as the value increases the text
is placed farther from the margin and outside
the plot, and as the value decreases the text is
placed inside the plot and farther from the
margin.
Code
dataCrunchmtext(): Line
Slide 19
# create a basic plot
plot(mtcars$disp, mtcars$mpg)
# place the text away from the plot
mtext("Sample Text", line = -1)
Description
The line argument places the text inside the
plot when the values is less than zero.
Code
dataCrunchmtext(): Line
Slide 20
The below plot depicts the appearance of the text when different options for line are applied:
dataCrunchmtext(): adj
Slide 21
# create a basic plot
plot(mtcars$disp, mtcars$mpg)
# align the text to the left
mtext("Sample Text", adj= 0)
Description
The adj argument is used for horizontal
alignment of the text. If set to 0, the text will be
left aligned and at 1, it will be right aligned.
Code
dataCrunchmtext(): adj
Slide 22
# create a basic plot
plot(mtcars$disp, mtcars$mpg)
# align the text to the right
mtext("Sample Text", adj= 1)
Description
When the value is set to 1, the text will be right
aligned.
Code
dataCrunchmtext(): adj
Slide 23
The below plot depicts the appearance of the text when different options for text() are applied:
dataCrunch
Slide 24
Visit dataCrunch for
tutorials on:
→ R Programming
→ Business Analytics
→ Data Visualization
→ Web Applications
→ Package Development
→ Git & GitHub

Más contenido relacionado

La actualidad más candente

La actualidad más candente (18)

Access intermediate 2010 final project new
Access intermediate 2010 final project newAccess intermediate 2010 final project new
Access intermediate 2010 final project new
 
Chapter13 two-dimensional-array
Chapter13 two-dimensional-arrayChapter13 two-dimensional-array
Chapter13 two-dimensional-array
 
An introduction to matlab
An introduction to matlabAn introduction to matlab
An introduction to matlab
 
R Programming: Numeric Functions In R
R Programming: Numeric Functions In RR Programming: Numeric Functions In R
R Programming: Numeric Functions In R
 
Extreme querying with_analytics
Extreme querying with_analyticsExtreme querying with_analytics
Extreme querying with_analytics
 
Lecture 1 mte 407
Lecture 1 mte 407Lecture 1 mte 407
Lecture 1 mte 407
 
Lecture 1 mte 407
Lecture 1 mte 407Lecture 1 mte 407
Lecture 1 mte 407
 
R studio
R studio R studio
R studio
 
Excel/R
Excel/RExcel/R
Excel/R
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
R-Excel Integration
R-Excel IntegrationR-Excel Integration
R-Excel Integration
 
11)recap forms and queries
11)recap forms and queries11)recap forms and queries
11)recap forms and queries
 
statistical computation using R- an intro..
statistical computation using R- an intro..statistical computation using R- an intro..
statistical computation using R- an intro..
 
Assigment 3
Assigment 3Assigment 3
Assigment 3
 
Doc 20180130-wa0004
Doc 20180130-wa0004Doc 20180130-wa0004
Doc 20180130-wa0004
 
Easy Blogging With Emacs -- Cheatsheet
Easy Blogging With Emacs -- CheatsheetEasy Blogging With Emacs -- Cheatsheet
Easy Blogging With Emacs -- Cheatsheet
 
Matlab Visualizing Data
Matlab Visualizing DataMatlab Visualizing Data
Matlab Visualizing Data
 
QMC: Undergraduate Workshop, Tutorial on 'R' Software - Yawen Guan, Feb 26, 2...
QMC: Undergraduate Workshop, Tutorial on 'R' Software - Yawen Guan, Feb 26, 2...QMC: Undergraduate Workshop, Tutorial on 'R' Software - Yawen Guan, Feb 26, 2...
QMC: Undergraduate Workshop, Tutorial on 'R' Software - Yawen Guan, Feb 26, 2...
 

Similar a R Data Visualization: Learn To Add Text Annotations To Plots

Text Layout With Core Text
Text Layout With Core TextText Layout With Core Text
Text Layout With Core TextDavid Ding
 
Unitii classnotes
Unitii classnotesUnitii classnotes
Unitii classnotesSowri Rajan
 
Unit-IV Strings.pptx
Unit-IV Strings.pptxUnit-IV Strings.pptx
Unit-IV Strings.pptxsamdamfa
 
Data Structure & Algorithms - Matrix Multiplication
Data Structure & Algorithms - Matrix MultiplicationData Structure & Algorithms - Matrix Multiplication
Data Structure & Algorithms - Matrix Multiplicationbabuk110
 
Introducton to Convolutional Nerural Network with TensorFlow
Introducton to Convolutional Nerural Network with TensorFlowIntroducton to Convolutional Nerural Network with TensorFlow
Introducton to Convolutional Nerural Network with TensorFlowEtsuji Nakai
 
R programming slides
R  programming slidesR  programming slides
R programming slidesPankaj Saini
 
Visualization and Matplotlib using Python.pptx
Visualization and Matplotlib using Python.pptxVisualization and Matplotlib using Python.pptx
Visualization and Matplotlib using Python.pptxSharmilaMore5
 
CIV1900 Matlab - Plotting & Coursework
CIV1900 Matlab - Plotting & CourseworkCIV1900 Matlab - Plotting & Coursework
CIV1900 Matlab - Plotting & CourseworkTUOS-Sam
 
Lesson 13. Pattern 5. Address arithmetic
Lesson 13. Pattern 5. Address arithmeticLesson 13. Pattern 5. Address arithmetic
Lesson 13. Pattern 5. Address arithmeticPVS-Studio
 
PART 3: THE SCRIPTING COMPOSER AND PYTHON
PART 3: THE SCRIPTING COMPOSER AND PYTHONPART 3: THE SCRIPTING COMPOSER AND PYTHON
PART 3: THE SCRIPTING COMPOSER AND PYTHONAndrea Antonello
 
R Programming.pptx
R Programming.pptxR Programming.pptx
R Programming.pptxkalai75
 

Similar a R Data Visualization: Learn To Add Text Annotations To Plots (20)

Lecture_3.pptx
Lecture_3.pptxLecture_3.pptx
Lecture_3.pptx
 
Basic Analysis using Python
Basic Analysis using PythonBasic Analysis using Python
Basic Analysis using Python
 
R data types
R   data typesR   data types
R data types
 
CPP Homework Help
CPP Homework HelpCPP Homework Help
CPP Homework Help
 
Introduction to r
Introduction to rIntroduction to r
Introduction to r
 
Text Layout With Core Text
Text Layout With Core TextText Layout With Core Text
Text Layout With Core Text
 
Unitii classnotes
Unitii classnotesUnitii classnotes
Unitii classnotes
 
Computer Science Assignment Help
Computer Science Assignment Help Computer Science Assignment Help
Computer Science Assignment Help
 
Unit-IV Strings.pptx
Unit-IV Strings.pptxUnit-IV Strings.pptx
Unit-IV Strings.pptx
 
MatplotLib.pptx
MatplotLib.pptxMatplotLib.pptx
MatplotLib.pptx
 
Data Structure & Algorithms - Matrix Multiplication
Data Structure & Algorithms - Matrix MultiplicationData Structure & Algorithms - Matrix Multiplication
Data Structure & Algorithms - Matrix Multiplication
 
Programming with matlab session 6
Programming with matlab session 6Programming with matlab session 6
Programming with matlab session 6
 
Introducton to Convolutional Nerural Network with TensorFlow
Introducton to Convolutional Nerural Network with TensorFlowIntroducton to Convolutional Nerural Network with TensorFlow
Introducton to Convolutional Nerural Network with TensorFlow
 
R programming slides
R  programming slidesR  programming slides
R programming slides
 
Visualization and Matplotlib using Python.pptx
Visualization and Matplotlib using Python.pptxVisualization and Matplotlib using Python.pptx
Visualization and Matplotlib using Python.pptx
 
CIV1900 Matlab - Plotting & Coursework
CIV1900 Matlab - Plotting & CourseworkCIV1900 Matlab - Plotting & Coursework
CIV1900 Matlab - Plotting & Coursework
 
Lesson 13. Pattern 5. Address arithmetic
Lesson 13. Pattern 5. Address arithmeticLesson 13. Pattern 5. Address arithmetic
Lesson 13. Pattern 5. Address arithmetic
 
Intake 37 6
Intake 37 6Intake 37 6
Intake 37 6
 
PART 3: THE SCRIPTING COMPOSER AND PYTHON
PART 3: THE SCRIPTING COMPOSER AND PYTHONPART 3: THE SCRIPTING COMPOSER AND PYTHON
PART 3: THE SCRIPTING COMPOSER AND PYTHON
 
R Programming.pptx
R Programming.pptxR Programming.pptx
R Programming.pptx
 

Más de Rsquared Academy

Market Basket Analysis in R
Market Basket Analysis in RMarket Basket Analysis in R
Market Basket Analysis in RRsquared Academy
 
Practical Introduction to Web scraping using R
Practical Introduction to Web scraping using RPractical Introduction to Web scraping using R
Practical Introduction to Web scraping using RRsquared Academy
 
Writing Readable Code with Pipes
Writing Readable Code with PipesWriting Readable Code with Pipes
Writing Readable Code with PipesRsquared Academy
 
Read data from Excel spreadsheets into R
Read data from Excel spreadsheets into RRead data from Excel spreadsheets into R
Read data from Excel spreadsheets into RRsquared Academy
 
Read/Import data from flat/delimited files into R
Read/Import data from flat/delimited files into RRead/Import data from flat/delimited files into R
Read/Import data from flat/delimited files into RRsquared Academy
 
Variables & Data Types in R
Variables & Data Types in RVariables & Data Types in R
Variables & Data Types in RRsquared Academy
 
How to install & update R packages?
How to install & update R packages?How to install & update R packages?
How to install & update R packages?Rsquared Academy
 
RMySQL Tutorial For Beginners
RMySQL Tutorial For BeginnersRMySQL Tutorial For Beginners
RMySQL Tutorial For BeginnersRsquared Academy
 
R Markdown Tutorial For Beginners
R Markdown Tutorial For BeginnersR Markdown Tutorial For Beginners
R Markdown Tutorial For BeginnersRsquared Academy
 
R Programming: Introduction to Matrices
R Programming: Introduction to MatricesR Programming: Introduction to Matrices
R Programming: Introduction to MatricesRsquared Academy
 
R Programming: Introduction to Vectors
R Programming: Introduction to VectorsR Programming: Introduction to Vectors
R Programming: Introduction to VectorsRsquared Academy
 
R Programming: Variables & Data Types
R Programming: Variables & Data TypesR Programming: Variables & Data Types
R Programming: Variables & Data TypesRsquared Academy
 
R Programming: Mathematical Functions In R
R Programming: Mathematical Functions In RR Programming: Mathematical Functions In R
R Programming: Mathematical Functions In RRsquared Academy
 

Más de Rsquared Academy (20)

Handling Date & Time in R
Handling Date & Time in RHandling Date & Time in R
Handling Date & Time in R
 
Market Basket Analysis in R
Market Basket Analysis in RMarket Basket Analysis in R
Market Basket Analysis in R
 
Practical Introduction to Web scraping using R
Practical Introduction to Web scraping using RPractical Introduction to Web scraping using R
Practical Introduction to Web scraping using R
 
Joining Data with dplyr
Joining Data with dplyrJoining Data with dplyr
Joining Data with dplyr
 
Explore Data using dplyr
Explore Data using dplyrExplore Data using dplyr
Explore Data using dplyr
 
Data Wrangling with dplyr
Data Wrangling with dplyrData Wrangling with dplyr
Data Wrangling with dplyr
 
Writing Readable Code with Pipes
Writing Readable Code with PipesWriting Readable Code with Pipes
Writing Readable Code with Pipes
 
Introduction to tibbles
Introduction to tibblesIntroduction to tibbles
Introduction to tibbles
 
Read data from Excel spreadsheets into R
Read data from Excel spreadsheets into RRead data from Excel spreadsheets into R
Read data from Excel spreadsheets into R
 
Read/Import data from flat/delimited files into R
Read/Import data from flat/delimited files into RRead/Import data from flat/delimited files into R
Read/Import data from flat/delimited files into R
 
Variables & Data Types in R
Variables & Data Types in RVariables & Data Types in R
Variables & Data Types in R
 
How to install & update R packages?
How to install & update R packages?How to install & update R packages?
How to install & update R packages?
 
How to get help in R?
How to get help in R?How to get help in R?
How to get help in R?
 
Introduction to R
Introduction to RIntroduction to R
Introduction to R
 
RMySQL Tutorial For Beginners
RMySQL Tutorial For BeginnersRMySQL Tutorial For Beginners
RMySQL Tutorial For Beginners
 
R Markdown Tutorial For Beginners
R Markdown Tutorial For BeginnersR Markdown Tutorial For Beginners
R Markdown Tutorial For Beginners
 
R Programming: Introduction to Matrices
R Programming: Introduction to MatricesR Programming: Introduction to Matrices
R Programming: Introduction to Matrices
 
R Programming: Introduction to Vectors
R Programming: Introduction to VectorsR Programming: Introduction to Vectors
R Programming: Introduction to Vectors
 
R Programming: Variables & Data Types
R Programming: Variables & Data TypesR Programming: Variables & Data Types
R Programming: Variables & Data Types
 
R Programming: Mathematical Functions In R
R Programming: Mathematical Functions In RR Programming: Mathematical Functions In R
R Programming: Mathematical Functions In R
 

Último

Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...
Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...
Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...gajnagarg
 
Reconciling Conflicting Data Curation Actions: Transparency Through Argument...
Reconciling Conflicting Data Curation Actions:  Transparency Through Argument...Reconciling Conflicting Data Curation Actions:  Transparency Through Argument...
Reconciling Conflicting Data Curation Actions: Transparency Through Argument...Bertram Ludäscher
 
怎样办理圣地亚哥州立大学毕业证(SDSU毕业证书)成绩单学校原版复制
怎样办理圣地亚哥州立大学毕业证(SDSU毕业证书)成绩单学校原版复制怎样办理圣地亚哥州立大学毕业证(SDSU毕业证书)成绩单学校原版复制
怎样办理圣地亚哥州立大学毕业证(SDSU毕业证书)成绩单学校原版复制vexqp
 
一比一原版(UCD毕业证书)加州大学戴维斯分校毕业证成绩单原件一模一样
一比一原版(UCD毕业证书)加州大学戴维斯分校毕业证成绩单原件一模一样一比一原版(UCD毕业证书)加州大学戴维斯分校毕业证成绩单原件一模一样
一比一原版(UCD毕业证书)加州大学戴维斯分校毕业证成绩单原件一模一样wsppdmt
 
Dubai Call Girls Peeing O525547819 Call Girls Dubai
Dubai Call Girls Peeing O525547819 Call Girls DubaiDubai Call Girls Peeing O525547819 Call Girls Dubai
Dubai Call Girls Peeing O525547819 Call Girls Dubaikojalkojal131
 
Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...nirzagarg
 
Lecture_2_Deep_Learning_Overview-newone1
Lecture_2_Deep_Learning_Overview-newone1Lecture_2_Deep_Learning_Overview-newone1
Lecture_2_Deep_Learning_Overview-newone1ranjankumarbehera14
 
Gartner's Data Analytics Maturity Model.pptx
Gartner's Data Analytics Maturity Model.pptxGartner's Data Analytics Maturity Model.pptx
Gartner's Data Analytics Maturity Model.pptxchadhar227
 
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...Klinik kandungan
 
Capstone in Interprofessional Informatic // IMPACT OF COVID 19 ON EDUCATION
Capstone in Interprofessional Informatic  // IMPACT OF COVID 19 ON EDUCATIONCapstone in Interprofessional Informatic  // IMPACT OF COVID 19 ON EDUCATION
Capstone in Interprofessional Informatic // IMPACT OF COVID 19 ON EDUCATIONLakpaYanziSherpa
 
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...gajnagarg
 
The-boAt-Story-Navigating-the-Waves-of-Innovation.pptx
The-boAt-Story-Navigating-the-Waves-of-Innovation.pptxThe-boAt-Story-Navigating-the-Waves-of-Innovation.pptx
The-boAt-Story-Navigating-the-Waves-of-Innovation.pptxVivek487417
 
怎样办理伦敦大学毕业证(UoL毕业证书)成绩单学校原版复制
怎样办理伦敦大学毕业证(UoL毕业证书)成绩单学校原版复制怎样办理伦敦大学毕业证(UoL毕业证书)成绩单学校原版复制
怎样办理伦敦大学毕业证(UoL毕业证书)成绩单学校原版复制vexqp
 
Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...
Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...
Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...gajnagarg
 
Top profile Call Girls In Begusarai [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In Begusarai [ 7014168258 ] Call Me For Genuine Models...Top profile Call Girls In Begusarai [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In Begusarai [ 7014168258 ] Call Me For Genuine Models...nirzagarg
 
Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...gajnagarg
 
如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样
如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样
如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样wsppdmt
 
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi ArabiaIn Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabiaahmedjiabur940
 

Último (20)

Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...
Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...
Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...
 
Reconciling Conflicting Data Curation Actions: Transparency Through Argument...
Reconciling Conflicting Data Curation Actions:  Transparency Through Argument...Reconciling Conflicting Data Curation Actions:  Transparency Through Argument...
Reconciling Conflicting Data Curation Actions: Transparency Through Argument...
 
怎样办理圣地亚哥州立大学毕业证(SDSU毕业证书)成绩单学校原版复制
怎样办理圣地亚哥州立大学毕业证(SDSU毕业证书)成绩单学校原版复制怎样办理圣地亚哥州立大学毕业证(SDSU毕业证书)成绩单学校原版复制
怎样办理圣地亚哥州立大学毕业证(SDSU毕业证书)成绩单学校原版复制
 
Cytotec in Jeddah+966572737505) get unwanted pregnancy kit Riyadh
Cytotec in Jeddah+966572737505) get unwanted pregnancy kit RiyadhCytotec in Jeddah+966572737505) get unwanted pregnancy kit Riyadh
Cytotec in Jeddah+966572737505) get unwanted pregnancy kit Riyadh
 
一比一原版(UCD毕业证书)加州大学戴维斯分校毕业证成绩单原件一模一样
一比一原版(UCD毕业证书)加州大学戴维斯分校毕业证成绩单原件一模一样一比一原版(UCD毕业证书)加州大学戴维斯分校毕业证成绩单原件一模一样
一比一原版(UCD毕业证书)加州大学戴维斯分校毕业证成绩单原件一模一样
 
Dubai Call Girls Peeing O525547819 Call Girls Dubai
Dubai Call Girls Peeing O525547819 Call Girls DubaiDubai Call Girls Peeing O525547819 Call Girls Dubai
Dubai Call Girls Peeing O525547819 Call Girls Dubai
 
Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...
 
Lecture_2_Deep_Learning_Overview-newone1
Lecture_2_Deep_Learning_Overview-newone1Lecture_2_Deep_Learning_Overview-newone1
Lecture_2_Deep_Learning_Overview-newone1
 
Gartner's Data Analytics Maturity Model.pptx
Gartner's Data Analytics Maturity Model.pptxGartner's Data Analytics Maturity Model.pptx
Gartner's Data Analytics Maturity Model.pptx
 
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
 
Capstone in Interprofessional Informatic // IMPACT OF COVID 19 ON EDUCATION
Capstone in Interprofessional Informatic  // IMPACT OF COVID 19 ON EDUCATIONCapstone in Interprofessional Informatic  // IMPACT OF COVID 19 ON EDUCATION
Capstone in Interprofessional Informatic // IMPACT OF COVID 19 ON EDUCATION
 
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...
 
The-boAt-Story-Navigating-the-Waves-of-Innovation.pptx
The-boAt-Story-Navigating-the-Waves-of-Innovation.pptxThe-boAt-Story-Navigating-the-Waves-of-Innovation.pptx
The-boAt-Story-Navigating-the-Waves-of-Innovation.pptx
 
怎样办理伦敦大学毕业证(UoL毕业证书)成绩单学校原版复制
怎样办理伦敦大学毕业证(UoL毕业证书)成绩单学校原版复制怎样办理伦敦大学毕业证(UoL毕业证书)成绩单学校原版复制
怎样办理伦敦大学毕业证(UoL毕业证书)成绩单学校原版复制
 
Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...
Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...
Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...
 
Top profile Call Girls In Begusarai [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In Begusarai [ 7014168258 ] Call Me For Genuine Models...Top profile Call Girls In Begusarai [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In Begusarai [ 7014168258 ] Call Me For Genuine Models...
 
Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...
 
如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样
如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样
如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样
 
Abortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Doha Qatar (+966572737505 ! Get CytotecAbortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Doha Qatar (+966572737505 ! Get Cytotec
 
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi ArabiaIn Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
 

R Data Visualization: Learn To Add Text Annotations To Plots

  • 1. www.r-squared.in/git-hub dataCrunch Data Visualization With R Learn To Add Text Annotations To Plots
  • 3. dataCrunchText Annotations: Objectives Slide 3 In this section, we will learn to: Add text annotations to the plots using ● text() function ● mtext() function
  • 4. dataCrunchText Annotations: Introduction Slide 4 The text() and the mtext() functions allow the user to add text annotations to the plots. While the text() function places the text inside the plot, the mtext() function places the text on the margins of the plot. Below is the syntax for both the functions: # the text function text(x, y = NULL, labels = seq_along(x), adj = NULL, pos = NULL, offset = 0.5, vfont = NULL, cex = 1, col = NULL, font = NULL, ...) # the mtext function mtext(text, side = 3, line = 0, outer = FALSE, at = NA, adj = NA, padj = NA, cex = NA, col = NA, font = NA, ...) Let us explore each function and its arguments one by one:
  • 5. dataCrunchText Annotations: text() Slide 5 To add text annotations using the text() function, the following 3 arguments must be supplied: ● x: x axis coordinate ● y: y axis coordinate ● text: the text to be added to the plot Below is a simple example: # create a basic plot plot(mtcars$disp, mtcars$mpg) # add text text(340, 30, "Sample Text") The text appears at the coordinates (340, 30) on the plot. Ensure that the text is enclosed in double quotes and the coordinates provided are within the range of the X and Y axis variable.
  • 6. dataCrunchtext(): Color Slide 6 # create a basic plot plot(mtcars$disp, mtcars$mpg) # modify the color of the text text(340, 30, "Sample Text", col = "red") Description The color of the text can be modified using the col argument in the text() function. Code
  • 7. dataCrunchtext(): Color Slide 7 The below plot depicts the appearance of the text when different options for col are applied:
  • 8. dataCrunchtext(): Font Slide 8 # create a basic plot plot(mtcars$disp, mtcars$mpg) # modify the font of the text text(340, 30, "Sample Text", font = 2) Description The font of the text can be modified using the font argument in the text() function. Code
  • 9. dataCrunchtext(): Font Slide 9 The below plot depicts the appearance of the text when different options for font are applied:
  • 10. dataCrunchtext(): Font Family Slide 10 # create a basic plot plot(mtcars$disp, mtcars$mpg) # modify the font family of the text text(340, 30, "Sample Text", family = mono) Description The font family of the text can be modified using the family argument in the text() function. Code
  • 11. dataCrunchtext(): Font Family Slide 11 The below plot depicts the appearance of the text when different options for font family are applied:
  • 12. dataCrunchtext(): Font Size Slide 12 # create a basic plot plot(mtcars$disp, mtcars$mpg) # modify the size of the text text(340, 30, "Sample Text", cex = 1.5) Description The size of the text can be modified using the cex argument in the text() function. Code
  • 13. dataCrunchtext(): Font Size Slide 13 The below plot depicts the appearance of the text when different options for font size are applied:
  • 14. dataCrunchmtext(): Introduction Slide 14 The mtext() function places text annotations on the margins of the plot instead of placing them inside the plot. It allows the user to modify the location of the text in multiple ways and we will explore them one by one. Below is a simple example: # create a basic plot plot(mtcars$disp, mtcars$mpg) # add text mtext("Sample Text") As you can see, the text is placed on the margin of the plot and not inside the plot. Next, we will learn to specify the margin where the text should be placed.
  • 15. dataCrunchmtext(): Margin Slide 15 # create a basic plot plot(mtcars$disp, mtcars$mpg) # specify the margin on which the text should appear mtext("Sample Text", side = 1) Description The margin on which we want to place the text can be specified using the side argument. It takes 4 values from 1-4 each representing one side of the plot. Code
  • 16. dataCrunchmtext(): Margin Options Slide 16 The side argument can be used to specify the margin on which the text should be placed. side Margin 1 Bottom 2 Left 3 Top 4 Right
  • 17. dataCrunchmtext(): Margin Slide 17 The below plot depicts the appearance of the text when different options for side are applied:
  • 18. dataCrunchmtext(): Line Slide 18 # create a basic plot plot(mtcars$disp, mtcars$mpg) # place the text away from the margin mtext("Sample Text", line = 1) Description The line argument places the text at the specified distance from the margin. The default value is 0 and as the value increases the text is placed farther from the margin and outside the plot, and as the value decreases the text is placed inside the plot and farther from the margin. Code
  • 19. dataCrunchmtext(): Line Slide 19 # create a basic plot plot(mtcars$disp, mtcars$mpg) # place the text away from the plot mtext("Sample Text", line = -1) Description The line argument places the text inside the plot when the values is less than zero. Code
  • 20. dataCrunchmtext(): Line Slide 20 The below plot depicts the appearance of the text when different options for line are applied:
  • 21. dataCrunchmtext(): adj Slide 21 # create a basic plot plot(mtcars$disp, mtcars$mpg) # align the text to the left mtext("Sample Text", adj= 0) Description The adj argument is used for horizontal alignment of the text. If set to 0, the text will be left aligned and at 1, it will be right aligned. Code
  • 22. dataCrunchmtext(): adj Slide 22 # create a basic plot plot(mtcars$disp, mtcars$mpg) # align the text to the right mtext("Sample Text", adj= 1) Description When the value is set to 1, the text will be right aligned. Code
  • 23. dataCrunchmtext(): adj Slide 23 The below plot depicts the appearance of the text when different options for text() are applied:
  • 24. dataCrunch Slide 24 Visit dataCrunch for tutorials on: → R Programming → Business Analytics → Data Visualization → Web Applications → Package Development → Git & GitHub