SlideShare a Scribd company logo
DATA VISUALIZATION WITH R:
FUNCTION PLOT()
Vladimir E. Bakhrushin,
Professor, D. Sc.
Vladimir.Bakhrushin@gmail.com
Function plot()
Function plot() is the main tool for 2D plotting in R.
If we have two vectors x, y of equal length, function plot(x,y)
allows us to get the graph of y(x) dependence.
If only one variable is given, we will get a graph for which set
vector provide the ordinate values and the points ordinal
numbers are abscissas.
Function plot()
Some arguments of the plot()
function
Function
plot()
pch
type
main
Vectors x, y
legend
cex
col
lty
Combining plots
There is an opportunity to combine several plots into one
overall graph using commands:
old.par <- par(mfrow=c(n,m))
…
par(old.par)
First command places in the window n×m plots (m
horizontally and n vertically).
The last command restores the default graphical parameters.
Between them we have to specify what charts must be built.
Graph types
Argument type give us an opportunity to change the view of
graph. It can take the following text values:
"p" – points (default option);
"l" – lines;
"b" – lines between points;
"c" - lines part alone of "b";
"o" – points over lines;
"h" – histogram;
"s", " S" – step curves ;
"n" – no points and lines.
Arguments of the plot() function
xlab and ylab – assignment of titles to the coordinate axes,
for example: xlab = "Year", ylab = "Gross domestic product"
xlim and ylim – setting the ranges of values displayed on the​​
abscissa and ordinate axes, respectively; default values of these
arguments are NULL
axes and ann – control of displaying axes and their names;
their values may be "TRUE" or "FALSE"
log – graph in logarithmic or semilogarithmic scale; it may
take values "x", "y" or "xy".
Graph types
Graph types
Titles and subtitles
Argument main is used for creating graph title. Graph subtitle
may be created with argument sub.
Titles and subtitles
Point character
To set point character we can use argument pch.
First way is to assign a numerical value to argument pch. It
may be taken from the interval 1 – 25 or 32 – 255.
Numbers from 32 to 127 correspond
to ASCII symbols, for example: 33 – !,
34 – ", 35 – # etc. Numbers from 128 to
255 give an opportunity to use some
other symbols, such as Cyrillic alphabet
letters, gothic and so on.
Point characters
Another way of setting point characters is combining of
arguments pch and font. The last defines a font of characters.
Default option is font = 1. For the most of other font values we
obtain different variants of writing the same symbols as in the
absence of this argument. For example, at font = 2 bold
characters are used, at font = 3 – italic, at font = 4 – bold italic
etc.
Also we can specify character type directly, for example: pch
= "&".
font = 5
Colors
To set the color of characters and some other elements we
can use argument col. Also in R there is a possibility to set colors
of individual chart elements. For example, col.main sets the title
color, col.lab – names of axes, col.axes – axes annotations etc.).
Here are the main ways to set colors:
 by name we can set 675 standard colors, for example: col
= "red"; all color names may be obtained with command
colors();
 by numeric code, for example: col = 3 (green);
 by RGB spectrum components, for example: col =
"#FF6347" (tomato).
Colors
Lines
For setting line type argument lty is used. There are 6
predetermined line types.
If it is necessary you can create your own line types. In this
case, the value of the argument lty is the text sequence of four
numbers from 1 to 9, for example: lty = "4241". This line consists
of the pattern, which includes two dashes of four units in length
and spaces which lengths are alternately equal to two or one
unit.
Line width may be set with argument lwd.
Line types
Line types
Line types
Lines ends and joining
Argument lend is used for setting the form of line ends.
It may take such values:
 0 (default) – rounded ends;
 1 – lines ends are straight and perpendicular to lines;
 2 – lines ends are straight and parallel to the coordinate
axes.
Form of lines joining is set with the argument ljoin. It may
take such values:
 0 (за замовченням) – rounded joining;
 1 – sharp-cornered joining;
 2 – truncated joining.
Lines ends and joining
Note that the need to hide the names of the axes in the
second graph is enough to specify only when setting the first
line.
Lines ends
Lines joining
Legend
To create the legend function legend() may be used.
Its arguments are: coordinates x and y of the legend
window, vector of the individual lines names, vectors indicated
colors, point characters, line types etc which correspond to
these lines. Argument bty indicates that it is necessary to create
a frame around the legend (value "y"), or that a frame should
not be created (value "n").
Legend
Література
1.An Introduction to R
2.Kelly Black. R Tutorial
3.Tutorial: Using plot() function
4.R Documentation: Generic X-Y Plotting
5.SPLUS/R Library: Notes From Roger's Seminars on R.
Graphing in R

More Related Content

What's hot

Recognition-of-tokens
Recognition-of-tokensRecognition-of-tokens
Recognition-of-tokens
Dattatray Gandhmal
 
Compilers
CompilersCompilers
Compiler Design Lecture Notes
Compiler Design Lecture NotesCompiler Design Lecture Notes
Compiler Design Lecture Notes
FellowBuddy.com
 
Finite Automata in compiler design
Finite Automata in compiler designFinite Automata in compiler design
Finite Automata in compiler design
Riazul Islam
 
Compiler design
Compiler designCompiler design
Compiler design
Thakur Ganeshsingh Thakur
 
Hashing
HashingHashing
Hashing
Amar Jukuntla
 
DATABASE CONSTRAINTS
DATABASE CONSTRAINTSDATABASE CONSTRAINTS
DATABASE CONSTRAINTS
sunanditaAnand
 
Ll(1) Parser in Compilers
Ll(1) Parser in CompilersLl(1) Parser in Compilers
Ll(1) Parser in Compilers
Mahbubur Rahman
 
Compiler Design
Compiler DesignCompiler Design
Compiler DesignMir Majid
 
Character set of c
Character set of cCharacter set of c
Character set of c
Chandrapriya Rediex
 
C++ Data Structure PPT.ppt
C++ Data Structure PPT.pptC++ Data Structure PPT.ppt
C++ Data Structure PPT.ppt
Mukesh Thakur
 
Phases of compiler
Phases of compilerPhases of compiler
Phases of compiler
Karan Deopura
 
Introduction to Compiler design
Introduction to Compiler design Introduction to Compiler design
Introduction to Compiler design
Dr. C.V. Suresh Babu
 
Role-of-lexical-analysis
Role-of-lexical-analysisRole-of-lexical-analysis
Role-of-lexical-analysis
Dattatray Gandhmal
 
Memory organization in computer architecture
Memory organization in computer architectureMemory organization in computer architecture
Memory organization in computer architecture
Faisal Hussain
 
basics of compiler design
basics of compiler designbasics of compiler design
basics of compiler design
Preeti Katiyar
 
The role of the parser and Error recovery strategies ppt in compiler design
The role of the parser and Error recovery strategies ppt in compiler designThe role of the parser and Error recovery strategies ppt in compiler design
The role of the parser and Error recovery strategies ppt in compiler design
Sadia Akter
 
Method overloading
Method overloadingMethod overloading
Method overloading
Lovely Professional University
 
Header files in c
Header files in cHeader files in c
Header files in c
HoneyChintal
 
Types of grammer - TOC
Types of grammer - TOCTypes of grammer - TOC
Types of grammer - TOC
AbhayDhupar
 

What's hot (20)

Recognition-of-tokens
Recognition-of-tokensRecognition-of-tokens
Recognition-of-tokens
 
Compilers
CompilersCompilers
Compilers
 
Compiler Design Lecture Notes
Compiler Design Lecture NotesCompiler Design Lecture Notes
Compiler Design Lecture Notes
 
Finite Automata in compiler design
Finite Automata in compiler designFinite Automata in compiler design
Finite Automata in compiler design
 
Compiler design
Compiler designCompiler design
Compiler design
 
Hashing
HashingHashing
Hashing
 
DATABASE CONSTRAINTS
DATABASE CONSTRAINTSDATABASE CONSTRAINTS
DATABASE CONSTRAINTS
 
Ll(1) Parser in Compilers
Ll(1) Parser in CompilersLl(1) Parser in Compilers
Ll(1) Parser in Compilers
 
Compiler Design
Compiler DesignCompiler Design
Compiler Design
 
Character set of c
Character set of cCharacter set of c
Character set of c
 
C++ Data Structure PPT.ppt
C++ Data Structure PPT.pptC++ Data Structure PPT.ppt
C++ Data Structure PPT.ppt
 
Phases of compiler
Phases of compilerPhases of compiler
Phases of compiler
 
Introduction to Compiler design
Introduction to Compiler design Introduction to Compiler design
Introduction to Compiler design
 
Role-of-lexical-analysis
Role-of-lexical-analysisRole-of-lexical-analysis
Role-of-lexical-analysis
 
Memory organization in computer architecture
Memory organization in computer architectureMemory organization in computer architecture
Memory organization in computer architecture
 
basics of compiler design
basics of compiler designbasics of compiler design
basics of compiler design
 
The role of the parser and Error recovery strategies ppt in compiler design
The role of the parser and Error recovery strategies ppt in compiler designThe role of the parser and Error recovery strategies ppt in compiler design
The role of the parser and Error recovery strategies ppt in compiler design
 
Method overloading
Method overloadingMethod overloading
Method overloading
 
Header files in c
Header files in cHeader files in c
Header files in c
 
Types of grammer - TOC
Types of grammer - TOCTypes of grammer - TOC
Types of grammer - TOC
 

Similar to Plot function in R

Lecture_3.pptx
Lecture_3.pptxLecture_3.pptx
Lecture_3.pptx
SungaleliYuen
 
Matlab ch1 (6)
Matlab ch1 (6)Matlab ch1 (6)
Matlab ch1 (6)
mohsinggg
 
Lesson in Strings for C Programming Lessons
Lesson in Strings for C Programming LessonsLesson in Strings for C Programming Lessons
Lesson in Strings for C Programming Lessons
JamesChristianGadian
 
Chart and graphs in R programming language
Chart and graphs in R programming language Chart and graphs in R programming language
Chart and graphs in R programming language
CHANDAN KUMAR
 
C UNIT-3 PREPARED BY M V B REDDY
C UNIT-3 PREPARED BY M V B REDDYC UNIT-3 PREPARED BY M V B REDDY
C UNIT-3 PREPARED BY M V B REDDYRajeshkumar Reddy
 
LISP: Data types in lisp
LISP: Data types in lispLISP: Data types in lisp
LISP: Data types in lisp
DataminingTools Inc
 
LISP: Data types in lisp
LISP: Data types in lispLISP: Data types in lisp
LISP: Data types in lisp
LISP Content
 
Constants
ConstantsConstants
STRINGS IN C MRS.SOWMYA JYOTHI.pdf
STRINGS IN C MRS.SOWMYA JYOTHI.pdfSTRINGS IN C MRS.SOWMYA JYOTHI.pdf
STRINGS IN C MRS.SOWMYA JYOTHI.pdf
SowmyaJyothi3
 
Type header file in c++ and its function
Type header file in c++ and its functionType header file in c++ and its function
Type header file in c++ and its functionFrankie Jones
 
Co&amp;al lecture-08
Co&amp;al lecture-08Co&amp;al lecture-08
Co&amp;al lecture-08
AbdulKarim563520
 
statistical computation using R- an intro..
statistical computation using R- an intro..statistical computation using R- an intro..
statistical computation using R- an intro..
Kamarudheen KV
 
Chapter Two(1)
Chapter Two(1)Chapter Two(1)
Chapter Two(1)bolovv
 
1. Introduction.pptx
1. Introduction.pptx1. Introduction.pptx
1. Introduction.pptx
SungaleliYuen
 
compiler Design course material chapter 2
compiler Design course material chapter 2compiler Design course material chapter 2
compiler Design course material chapter 2
gadisaAdamu
 
Python programming unit 2 -Slides-3.ppt
Python programming  unit 2 -Slides-3.pptPython programming  unit 2 -Slides-3.ppt
Python programming unit 2 -Slides-3.ppt
geethar79
 
COM1407: Type Casting, Command Line Arguments and Defining Constants
COM1407: Type Casting, Command Line Arguments and Defining Constants COM1407: Type Casting, Command Line Arguments and Defining Constants
COM1407: Type Casting, Command Line Arguments and Defining Constants
Hemantha Kulathilake
 
ANSI C REFERENCE CARD
ANSI C REFERENCE CARDANSI C REFERENCE CARD
ANSI C REFERENCE CARD
Tia Ricci
 

Similar to Plot function in R (20)

Lecture_3.pptx
Lecture_3.pptxLecture_3.pptx
Lecture_3.pptx
 
Matlab ch1 (6)
Matlab ch1 (6)Matlab ch1 (6)
Matlab ch1 (6)
 
Lesson in Strings for C Programming Lessons
Lesson in Strings for C Programming LessonsLesson in Strings for C Programming Lessons
Lesson in Strings for C Programming Lessons
 
Chart and graphs in R programming language
Chart and graphs in R programming language Chart and graphs in R programming language
Chart and graphs in R programming language
 
C UNIT-3 PREPARED BY M V B REDDY
C UNIT-3 PREPARED BY M V B REDDYC UNIT-3 PREPARED BY M V B REDDY
C UNIT-3 PREPARED BY M V B REDDY
 
Strings and pointers
Strings and pointersStrings and pointers
Strings and pointers
 
LISP: Data types in lisp
LISP: Data types in lispLISP: Data types in lisp
LISP: Data types in lisp
 
LISP: Data types in lisp
LISP: Data types in lispLISP: Data types in lisp
LISP: Data types in lisp
 
Constants
ConstantsConstants
Constants
 
STRINGS IN C MRS.SOWMYA JYOTHI.pdf
STRINGS IN C MRS.SOWMYA JYOTHI.pdfSTRINGS IN C MRS.SOWMYA JYOTHI.pdf
STRINGS IN C MRS.SOWMYA JYOTHI.pdf
 
Type header file in c++ and its function
Type header file in c++ and its functionType header file in c++ and its function
Type header file in c++ and its function
 
Co&amp;al lecture-08
Co&amp;al lecture-08Co&amp;al lecture-08
Co&amp;al lecture-08
 
statistical computation using R- an intro..
statistical computation using R- an intro..statistical computation using R- an intro..
statistical computation using R- an intro..
 
Chapter Two(1)
Chapter Two(1)Chapter Two(1)
Chapter Two(1)
 
1. Introduction.pptx
1. Introduction.pptx1. Introduction.pptx
1. Introduction.pptx
 
compiler Design course material chapter 2
compiler Design course material chapter 2compiler Design course material chapter 2
compiler Design course material chapter 2
 
Python programming unit 2 -Slides-3.ppt
Python programming  unit 2 -Slides-3.pptPython programming  unit 2 -Slides-3.ppt
Python programming unit 2 -Slides-3.ppt
 
302 sargent word2007-ssp2008
302 sargent word2007-ssp2008302 sargent word2007-ssp2008
302 sargent word2007-ssp2008
 
COM1407: Type Casting, Command Line Arguments and Defining Constants
COM1407: Type Casting, Command Line Arguments and Defining Constants COM1407: Type Casting, Command Line Arguments and Defining Constants
COM1407: Type Casting, Command Line Arguments and Defining Constants
 
ANSI C REFERENCE CARD
ANSI C REFERENCE CARDANSI C REFERENCE CARD
ANSI C REFERENCE CARD
 

More from Vladimir Bakhrushin

Decision-making on assessment of higher education institutions under uncertainty
Decision-making on assessment of higher education institutions under uncertaintyDecision-making on assessment of higher education institutions under uncertainty
Decision-making on assessment of higher education institutions under uncertainty
Vladimir Bakhrushin
 
Якими бути стандартам вищої освіти для докторів філософії
Якими бути стандартам вищої освіти для докторів філософіїЯкими бути стандартам вищої освіти для докторів філософії
Якими бути стандартам вищої освіти для докторів філософії
Vladimir Bakhrushin
 
Академічна автономія і трансформація української освіти
Академічна автономія і трансформація української освітиАкадемічна автономія і трансформація української освіти
Академічна автономія і трансформація української освіти
Vladimir Bakhrushin
 
Оптимізація в освіті і управлінні
Оптимізація в освіті і управлінні Оптимізація в освіті і управлінні
Оптимізація в освіті і управлінні
Vladimir Bakhrushin
 
Мій 2015
Мій 2015Мій 2015
Мій 2015
Vladimir Bakhrushin
 
Українські університети: Сучасні виклики та можливі відповіді
Українські університети: Сучасні виклики та можливі відповідіУкраїнські університети: Сучасні виклики та можливі відповіді
Українські університети: Сучасні виклики та можливі відповіді
Vladimir Bakhrushin
 
Два проекти закону україни
Два проекти закону україниДва проекти закону україни
Два проекти закону україни
Vladimir Bakhrushin
 
Окремі аспекти реформування освіти України з погляду системного підходу
Окремі аспекти реформування освіти України з погляду системного підходуОкремі аспекти реформування освіти України з погляду системного підходу
Окремі аспекти реформування освіти України з погляду системного підходу
Vladimir Bakhrushin
 
Decision-making in education based on multi-criteria ranking of alternatives
Decision-making in education based on multi-criteria ranking of alternativesDecision-making in education based on multi-criteria ranking of alternatives
Decision-making in education based on multi-criteria ranking of alternatives
Vladimir Bakhrushin
 
Деякі проблеми прийняття рішень в освіті
Деякі проблеми прийняття рішень в освітіДеякі проблеми прийняття рішень в освіті
Деякі проблеми прийняття рішень в освіті
Vladimir Bakhrushin
 
Закон про освіту
Закон про освітуЗакон про освіту
Закон про освіту
Vladimir Bakhrushin
 
Описова статистика в R
Описова статистика в RОписова статистика в R
Описова статистика в R
Vladimir Bakhrushin
 
Деякі графічні засоби R
Деякі графічні засоби RДеякі графічні засоби R
Деякі графічні засоби R
Vladimir Bakhrushin
 
Функція plot() в R
Функція plot() в RФункція plot() в R
Функція plot() в R
Vladimir Bakhrushin
 
Files,blocks and functions in R
Files,blocks and functions in RFiles,blocks and functions in R
Files,blocks and functions in R
Vladimir Bakhrushin
 
Робота з файлами даних в R, блоки виразів, цикли, функції
Робота з файлами даних в R, блоки виразів, цикли, функціїРобота з файлами даних в R, блоки виразів, цикли, функції
Робота з файлами даних в R, блоки виразів, цикли, функції
Vladimir Bakhrushin
 
Cluster analysis using k-means method in R
Cluster analysis using k-means method in RCluster analysis using k-means method in R
Cluster analysis using k-means method in R
Vladimir Bakhrushin
 
Нові застосування статистичних методів в прикладних дослідженнях
Нові застосування статистичних методів в прикладних дослідженняхНові застосування статистичних методів в прикладних дослідженнях
Нові застосування статистичних методів в прикладних дослідженнях
Vladimir Bakhrushin
 
Парадоксы голосования
Парадоксы голосованияПарадоксы голосования
Парадоксы голосования
Vladimir Bakhrushin
 
Starting work with R
Starting work with RStarting work with R
Starting work with R
Vladimir Bakhrushin
 

More from Vladimir Bakhrushin (20)

Decision-making on assessment of higher education institutions under uncertainty
Decision-making on assessment of higher education institutions under uncertaintyDecision-making on assessment of higher education institutions under uncertainty
Decision-making on assessment of higher education institutions under uncertainty
 
Якими бути стандартам вищої освіти для докторів філософії
Якими бути стандартам вищої освіти для докторів філософіїЯкими бути стандартам вищої освіти для докторів філософії
Якими бути стандартам вищої освіти для докторів філософії
 
Академічна автономія і трансформація української освіти
Академічна автономія і трансформація української освітиАкадемічна автономія і трансформація української освіти
Академічна автономія і трансформація української освіти
 
Оптимізація в освіті і управлінні
Оптимізація в освіті і управлінні Оптимізація в освіті і управлінні
Оптимізація в освіті і управлінні
 
Мій 2015
Мій 2015Мій 2015
Мій 2015
 
Українські університети: Сучасні виклики та можливі відповіді
Українські університети: Сучасні виклики та можливі відповідіУкраїнські університети: Сучасні виклики та можливі відповіді
Українські університети: Сучасні виклики та можливі відповіді
 
Два проекти закону україни
Два проекти закону україниДва проекти закону україни
Два проекти закону україни
 
Окремі аспекти реформування освіти України з погляду системного підходу
Окремі аспекти реформування освіти України з погляду системного підходуОкремі аспекти реформування освіти України з погляду системного підходу
Окремі аспекти реформування освіти України з погляду системного підходу
 
Decision-making in education based on multi-criteria ranking of alternatives
Decision-making in education based on multi-criteria ranking of alternativesDecision-making in education based on multi-criteria ranking of alternatives
Decision-making in education based on multi-criteria ranking of alternatives
 
Деякі проблеми прийняття рішень в освіті
Деякі проблеми прийняття рішень в освітіДеякі проблеми прийняття рішень в освіті
Деякі проблеми прийняття рішень в освіті
 
Закон про освіту
Закон про освітуЗакон про освіту
Закон про освіту
 
Описова статистика в R
Описова статистика в RОписова статистика в R
Описова статистика в R
 
Деякі графічні засоби R
Деякі графічні засоби RДеякі графічні засоби R
Деякі графічні засоби R
 
Функція plot() в R
Функція plot() в RФункція plot() в R
Функція plot() в R
 
Files,blocks and functions in R
Files,blocks and functions in RFiles,blocks and functions in R
Files,blocks and functions in R
 
Робота з файлами даних в R, блоки виразів, цикли, функції
Робота з файлами даних в R, блоки виразів, цикли, функціїРобота з файлами даних в R, блоки виразів, цикли, функції
Робота з файлами даних в R, блоки виразів, цикли, функції
 
Cluster analysis using k-means method in R
Cluster analysis using k-means method in RCluster analysis using k-means method in R
Cluster analysis using k-means method in R
 
Нові застосування статистичних методів в прикладних дослідженнях
Нові застосування статистичних методів в прикладних дослідженняхНові застосування статистичних методів в прикладних дослідженнях
Нові застосування статистичних методів в прикладних дослідженнях
 
Парадоксы голосования
Парадоксы голосованияПарадоксы голосования
Парадоксы голосования
 
Starting work with R
Starting work with RStarting work with R
Starting work with R
 

Recently uploaded

GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
Nguyen Thanh Tu Collection
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
Excellence Foundation for South Sudan
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
Vivekanand Anglo Vedic Academy
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
Fundacja Rozwoju Społeczeństwa Przedsiębiorczego
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
EduSkills OECD
 

Recently uploaded (20)

GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 

Plot function in R

  • 1. DATA VISUALIZATION WITH R: FUNCTION PLOT() Vladimir E. Bakhrushin, Professor, D. Sc. Vladimir.Bakhrushin@gmail.com
  • 2. Function plot() Function plot() is the main tool for 2D plotting in R. If we have two vectors x, y of equal length, function plot(x,y) allows us to get the graph of y(x) dependence. If only one variable is given, we will get a graph for which set vector provide the ordinate values and the points ordinal numbers are abscissas.
  • 4. Some arguments of the plot() function Function plot() pch type main Vectors x, y legend cex col lty
  • 5. Combining plots There is an opportunity to combine several plots into one overall graph using commands: old.par <- par(mfrow=c(n,m)) … par(old.par) First command places in the window n×m plots (m horizontally and n vertically). The last command restores the default graphical parameters. Between them we have to specify what charts must be built.
  • 6. Graph types Argument type give us an opportunity to change the view of graph. It can take the following text values: "p" – points (default option); "l" – lines; "b" – lines between points; "c" - lines part alone of "b"; "o" – points over lines; "h" – histogram; "s", " S" – step curves ; "n" – no points and lines.
  • 7. Arguments of the plot() function xlab and ylab – assignment of titles to the coordinate axes, for example: xlab = "Year", ylab = "Gross domestic product" xlim and ylim – setting the ranges of values displayed on the​​ abscissa and ordinate axes, respectively; default values of these arguments are NULL axes and ann – control of displaying axes and their names; their values may be "TRUE" or "FALSE" log – graph in logarithmic or semilogarithmic scale; it may take values "x", "y" or "xy".
  • 10. Titles and subtitles Argument main is used for creating graph title. Graph subtitle may be created with argument sub.
  • 12. Point character To set point character we can use argument pch. First way is to assign a numerical value to argument pch. It may be taken from the interval 1 – 25 or 32 – 255. Numbers from 32 to 127 correspond to ASCII symbols, for example: 33 – !, 34 – ", 35 – # etc. Numbers from 128 to 255 give an opportunity to use some other symbols, such as Cyrillic alphabet letters, gothic and so on.
  • 13. Point characters Another way of setting point characters is combining of arguments pch and font. The last defines a font of characters. Default option is font = 1. For the most of other font values we obtain different variants of writing the same symbols as in the absence of this argument. For example, at font = 2 bold characters are used, at font = 3 – italic, at font = 4 – bold italic etc. Also we can specify character type directly, for example: pch = "&".
  • 15. Colors To set the color of characters and some other elements we can use argument col. Also in R there is a possibility to set colors of individual chart elements. For example, col.main sets the title color, col.lab – names of axes, col.axes – axes annotations etc.). Here are the main ways to set colors:  by name we can set 675 standard colors, for example: col = "red"; all color names may be obtained with command colors();  by numeric code, for example: col = 3 (green);  by RGB spectrum components, for example: col = "#FF6347" (tomato).
  • 17. Lines For setting line type argument lty is used. There are 6 predetermined line types. If it is necessary you can create your own line types. In this case, the value of the argument lty is the text sequence of four numbers from 1 to 9, for example: lty = "4241". This line consists of the pattern, which includes two dashes of four units in length and spaces which lengths are alternately equal to two or one unit. Line width may be set with argument lwd.
  • 21. Lines ends and joining Argument lend is used for setting the form of line ends. It may take such values:  0 (default) – rounded ends;  1 – lines ends are straight and perpendicular to lines;  2 – lines ends are straight and parallel to the coordinate axes. Form of lines joining is set with the argument ljoin. It may take such values:  0 (за замовченням) – rounded joining;  1 – sharp-cornered joining;  2 – truncated joining.
  • 22. Lines ends and joining Note that the need to hide the names of the axes in the second graph is enough to specify only when setting the first line.
  • 25. Legend To create the legend function legend() may be used. Its arguments are: coordinates x and y of the legend window, vector of the individual lines names, vectors indicated colors, point characters, line types etc which correspond to these lines. Argument bty indicates that it is necessary to create a frame around the legend (value "y"), or that a frame should not be created (value "n").
  • 27. Література 1.An Introduction to R 2.Kelly Black. R Tutorial 3.Tutorial: Using plot() function 4.R Documentation: Generic X-Y Plotting 5.SPLUS/R Library: Notes From Roger's Seminars on R. Graphing in R