SlideShare a Scribd company logo
1/40
Tools for Research Plotting
01
Mrs. Nimrita Koul
School of Computing & IT
Contents
• Python Plots - matplotlib
• R Plots
3
Download Options for Python
• www.python.org/downloads
• https://www.anaconda.com/download/
• Installing Matplotlib
• python -m pip install -U matplotlib
• conda install -c conda-forge matplotlib
4
matplotlib Dependencies
• Python (>= 3.5)
• FreeType (>= 2.3)
• libpng (>= 1.2)
• NumPy (>= 1.10.0)
• setuptools
• cycler (>= 0.10.0)
• dateutil (>= 2.1)
• kiwisolver (>= 1.0.0)
• pyparsing
5
6
matplotlip
Most used Python
package for 2D-
graphics
pyplot provides a
convenient interface
to the matplotlib
very quick
Publication-
quality figures
in many formats
7
8
Examples
9
10
11
12
13
14
15
16
Other Types of Plots in matplotlib
17
18
R Plots
19
Installing R
20
Installing R-Studio
21
R Studio
22
• An IDE for R
• Runs on Windows, Mac OS X and Linux
• RStudio project has following folders for default content
types:
 code: source code
 data: raw data, cleaned data
 figures: charts and graphs
 docs: documents and reports
 models: analytics models
R Plots
• > cars <- c(1, 3, 6, 4, 9)
• > plot(cars)
23
• cars <- c(1, 3, 6, 4, 9)
• # Graph cars using blue points overlayed by a
line
• plot(cars, type="o", col="blue")
• # Create a title with a red, bold/italic font
• title(main="Autos", col.main="red", font.main=4)
24
• # Define 2 vectors
• cars <- c(1, 3, 6, 4, 9)
• trucks <- c(2, 5, 4, 5, 12)
• # Graph cars using a y axis that ranges from 0 to 12
• plot(cars, type="o", col="blue", ylim=c(0,12))
• # Graph trucks with red dashed line and square points
• lines(trucks, type="o", pch=22, lty=2, col="red")
• # Create a title with a red, bold/italic font
• title(main="Autos", col.main="red", font.main=4)
25
26
• # Define 2 vectors
• cars <- c(1, 3, 6, 4, 9)
• trucks <- c(2, 5, 4, 5, 12)
• # Calculate range from 0 to max value of cars and trucks
• g_range <- range(0, cars, trucks)
• # Graph autos using y axis that ranges from 0 to max value in cars or trucks vector.
#Turn off axes and annotations (axis labels) so we can specify them our self
• plot(cars, type="o", col="blue", ylim=g_range, axes=FALSE, ann=FALSE)
• # Make x axis using Mon-Fri labels
• axis(1, at=1:5, lab=c("Mon","Tue","Wed","Thu","Fri"))
• # Make y axis with horizontal labels that display ticks at every 4 marks.
#4*0:g_range[2] is equivalent to c(0,4,8,12).
• axis(2, las=1, at=4*0:g_range[2])
27
• # Create box around plot
• box()
• # Graph trucks with red dashed line and square points
• lines(trucks, type="o", pch=22, lty=2, col="red")
• # Create a title with a red, bold/italic font
• title(main="Autos", col.main="red", font.main=4)
• # Label the x and y axes with dark green text
• title(xlab="Days", col.lab=rgb(0,0.5,0))
• title(ylab="Total", col.lab=rgb(0,0.5,0))
• # Create a legend at (1, g_range[2]) that is slightly smaller # (cex) and uses the same
#line colors and points used by the actual plots
• legend(1, g_range[2], c("cars","trucks"), cex=0.8,
• col=c("blue","red"), pch=21:22, lty=1:2);
28
Result
29
Plotting from a file• # Read car and truck values from tab-delimited autos.dat
• autos_data <- read.table("C:/R/autos.dat", header=T, sep="t")
• # Compute the largest y value used in the data (or we could # just use range again)
• max_y <- max(autos_data)
• # Define colors to be used for cars, trucks, suvs
• plot_colors <- c("blue","red","forestgreen")
• # Start PNG device driver to save output to figure.png
• png(filename="C:/R/figure.png", height=295, width=300, bg="white")
• # Graph autos using y axis that ranges from 0 to max_y. # Turn off axes and annotations (axis labels) so we can
• # specify them ourself
• plot(autos_data$cars, type="o", col=plot_colors[1], ylim=c(0,max_y), axes=FALSE, ann=FALSE)
• # Make x axis using Mon-Fri labels
• axis(1, at=1:5, lab=c("Mon", "Tue", "Wed", "Thu", "Fri"))
• # Make y axis with horizontal labels that display ticks at every 4 marks. 4*0:max_y is equivalent to c(0,4,8,12).
• axis(2, las=1, at=4*0:max_y)
30
• # Create box around plot
• box()
• # Graph trucks with red dashed line and square points
• lines(autos_data$trucks, type="o", pch=22, lty=2, col=plot_colors[2])
• # Graph suvs with green dotted line and diamond points
• lines(autos_data$suvs, type="o", pch=23, lty=3, col=plot_colors[3])
• # Create a title with a red, bold/italic font
• title(main="Autos", col.main="red", font.main=4)
• # Label the x and y axes with dark green text
• title(xlab= "Days", col.lab=rgb(0,0.5,0))
• title(ylab= "Total", col.lab=rgb(0,0.5,0))
• # Create a legend at (1, max_y) that is slightly smaller # (cex) and uses the same line colors and points used by
• # the actual plots
• legend(1, max_y, names(autos_data), cex=0.8, col=plot_colors, pch=21:23, lty=1:3);
•
• # Turn off device driver (to flush output to png)
• dev.off()
31
Plot from data in auto.dat
32
Bar charts
• # Read values from tab-delimited autos.dat
• autos_data <- read.table("C:/R/autos.dat", header=T,
sep="t")
• # Graph cars with specified labels for axes. Use blue
• # borders and diagnal lines in bars.
• barplot(autos_data$cars, main="Cars", xlab="Days",
• ylab="Total", names.arg=
c("Mon","Tue","Wed","Thu","Fri"),
• border="blue", density=c(10,20,30,40,50))
33
34
Other Plots in R
35
36
37
38
39
40
Tools for research plotting

More Related Content

What's hot

Chapter13 two-dimensional-array
Chapter13 two-dimensional-arrayChapter13 two-dimensional-array
Chapter13 two-dimensional-arrayDeepak Singh
 
4.5 sec and csc worked 3rd
4.5   sec and csc worked 3rd4.5   sec and csc worked 3rd
4.5 sec and csc worked 3rd
Jonna Ramsey
 
4.5 tan and cot.ppt worked
4.5   tan and cot.ppt worked4.5   tan and cot.ppt worked
4.5 tan and cot.ppt worked
Jonna Ramsey
 
R forecasting Example
R forecasting ExampleR forecasting Example
R forecasting Example
Dr. Volkan OBAN
 
IGraph a tool to analyze your network
IGraph a tool to analyze your networkIGraph a tool to analyze your network
IGraph a tool to analyze your network
Pushpendra Tiwari
 
RBootcamp Day 4
RBootcamp Day 4RBootcamp Day 4
RBootcamp Day 4
Olga Scrivner
 
10 - Scala. Co-product type (sum type)
10 - Scala. Co-product type (sum type)10 - Scala. Co-product type (sum type)
10 - Scala. Co-product type (sum type)
Roman Brovko
 
Examplelf flowchart
Examplelf flowchartExamplelf flowchart
Examplelf flowchart
Ankit Dubey
 
Butterfly Counting in Bipartite Networks
Butterfly Counting in Bipartite NetworksButterfly Counting in Bipartite Networks
Butterfly Counting in Bipartite Networks
Seyed-Vahid Sanei-Mehri
 
[TechPlayConf]Rekognition導入事例
[TechPlayConf]Rekognition導入事例[TechPlayConf]Rekognition導入事例
[TechPlayConf]Rekognition導入事例
Shinji Miyazato
 
Loom at Clojure/West
Loom at Clojure/WestLoom at Clojure/West
Loom at Clojure/West
Aysylu Greenberg
 
Loom & Functional Graphs in Clojure @ LambdaConf 2015
Loom & Functional Graphs in Clojure @ LambdaConf 2015Loom & Functional Graphs in Clojure @ LambdaConf 2015
Loom & Functional Graphs in Clojure @ LambdaConf 2015
Aysylu Greenberg
 
Loom and Graphs in Clojure
Loom and Graphs in ClojureLoom and Graphs in Clojure
Loom and Graphs in Clojure
Aysylu Greenberg
 
Scalaエンジニアのためのモナド入門
Scalaエンジニアのためのモナド入門Scalaエンジニアのためのモナド入門
Scalaエンジニアのためのモナド入門
Takashi Imahiro
 
RBootcam Day 2
RBootcam Day 2RBootcam Day 2
RBootcam Day 2
Olga Scrivner
 
La R Users Group Survey Of R Graphics
La R Users Group Survey Of R GraphicsLa R Users Group Survey Of R Graphics
La R Users Group Survey Of R Graphics
guest43ed8709
 

What's hot (18)

Chapter13 two-dimensional-array
Chapter13 two-dimensional-arrayChapter13 two-dimensional-array
Chapter13 two-dimensional-array
 
4.5 sec and csc worked 3rd
4.5   sec and csc worked 3rd4.5   sec and csc worked 3rd
4.5 sec and csc worked 3rd
 
4.5 tan and cot.ppt worked
4.5   tan and cot.ppt worked4.5   tan and cot.ppt worked
4.5 tan and cot.ppt worked
 
R forecasting Example
R forecasting ExampleR forecasting Example
R forecasting Example
 
IGraph a tool to analyze your network
IGraph a tool to analyze your networkIGraph a tool to analyze your network
IGraph a tool to analyze your network
 
Module 2 topic 2 notes
Module 2 topic 2 notesModule 2 topic 2 notes
Module 2 topic 2 notes
 
Kwp2 091217
Kwp2 091217Kwp2 091217
Kwp2 091217
 
RBootcamp Day 4
RBootcamp Day 4RBootcamp Day 4
RBootcamp Day 4
 
10 - Scala. Co-product type (sum type)
10 - Scala. Co-product type (sum type)10 - Scala. Co-product type (sum type)
10 - Scala. Co-product type (sum type)
 
Examplelf flowchart
Examplelf flowchartExamplelf flowchart
Examplelf flowchart
 
Butterfly Counting in Bipartite Networks
Butterfly Counting in Bipartite NetworksButterfly Counting in Bipartite Networks
Butterfly Counting in Bipartite Networks
 
[TechPlayConf]Rekognition導入事例
[TechPlayConf]Rekognition導入事例[TechPlayConf]Rekognition導入事例
[TechPlayConf]Rekognition導入事例
 
Loom at Clojure/West
Loom at Clojure/WestLoom at Clojure/West
Loom at Clojure/West
 
Loom & Functional Graphs in Clojure @ LambdaConf 2015
Loom & Functional Graphs in Clojure @ LambdaConf 2015Loom & Functional Graphs in Clojure @ LambdaConf 2015
Loom & Functional Graphs in Clojure @ LambdaConf 2015
 
Loom and Graphs in Clojure
Loom and Graphs in ClojureLoom and Graphs in Clojure
Loom and Graphs in Clojure
 
Scalaエンジニアのためのモナド入門
Scalaエンジニアのためのモナド入門Scalaエンジニアのためのモナド入門
Scalaエンジニアのためのモナド入門
 
RBootcam Day 2
RBootcam Day 2RBootcam Day 2
RBootcam Day 2
 
La R Users Group Survey Of R Graphics
La R Users Group Survey Of R GraphicsLa R Users Group Survey Of R Graphics
La R Users Group Survey Of R Graphics
 

Similar to Tools for research plotting

Introduction to Data Visualization,Matplotlib.pdf
Introduction to Data Visualization,Matplotlib.pdfIntroduction to Data Visualization,Matplotlib.pdf
Introduction to Data Visualization,Matplotlib.pdf
sumitt6_25730773
 
Presentation: Plotting Systems in R
Presentation: Plotting Systems in RPresentation: Plotting Systems in R
Presentation: Plotting Systems in R
Ilya Zhbannikov
 
Migrating from matlab to python
Migrating from matlab to pythonMigrating from matlab to python
Migrating from matlab to pythonActiveState
 
Learning notes of r for python programmer (Temp1)
Learning notes of r for python programmer (Temp1)Learning notes of r for python programmer (Temp1)
Learning notes of r for python programmer (Temp1)Chia-Chi Chang
 
Ch1
Ch1Ch1
UNit-III. part 2.pdf
UNit-III. part 2.pdfUNit-III. part 2.pdf
UNit-III. part 2.pdf
MastiCreation
 
Big datacourse
Big datacourseBig datacourse
Big datacourse
Massimiliano Ruocco
 
Exploratory data analysis using r
Exploratory data analysis using rExploratory data analysis using r
Exploratory data analysis using r
Tahera Shaikh
 
An overview of Python 2.7
An overview of Python 2.7An overview of Python 2.7
An overview of Python 2.7
decoupled
 
A tour of Python
A tour of PythonA tour of Python
A tour of Python
Aleksandar Veselinovic
 
4.ArraysInC.pdf
4.ArraysInC.pdf4.ArraysInC.pdf
4.ArraysInC.pdf
FarHanWasif1
 
Introduction to matplotlib
Introduction to matplotlibIntroduction to matplotlib
Introduction to matplotlib
Piyush rai
 
Lecture 02 visualization and programming
Lecture 02   visualization and programmingLecture 02   visualization and programming
Lecture 02 visualization and programming
Smee Kaem Chann
 
2CPP06 - Arrays and Pointers
2CPP06 - Arrays and Pointers2CPP06 - Arrays and Pointers
2CPP06 - Arrays and Pointers
Michael Heron
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
Khulna University
 
Modern C++
Modern C++Modern C++
Modern C++
Michael Clark
 
hadoop introduce
hadoop introducehadoop introduce
hadoop introducejustlooks
 

Similar to Tools for research plotting (20)

Introduction to Data Visualization,Matplotlib.pdf
Introduction to Data Visualization,Matplotlib.pdfIntroduction to Data Visualization,Matplotlib.pdf
Introduction to Data Visualization,Matplotlib.pdf
 
Presentation: Plotting Systems in R
Presentation: Plotting Systems in RPresentation: Plotting Systems in R
Presentation: Plotting Systems in R
 
Lec2
Lec2Lec2
Lec2
 
Migrating from matlab to python
Migrating from matlab to pythonMigrating from matlab to python
Migrating from matlab to python
 
MATLAB & Image Processing
MATLAB & Image ProcessingMATLAB & Image Processing
MATLAB & Image Processing
 
Learning notes of r for python programmer (Temp1)
Learning notes of r for python programmer (Temp1)Learning notes of r for python programmer (Temp1)
Learning notes of r for python programmer (Temp1)
 
Intro matlab
Intro matlabIntro matlab
Intro matlab
 
Ch1
Ch1Ch1
Ch1
 
UNit-III. part 2.pdf
UNit-III. part 2.pdfUNit-III. part 2.pdf
UNit-III. part 2.pdf
 
Big datacourse
Big datacourseBig datacourse
Big datacourse
 
Exploratory data analysis using r
Exploratory data analysis using rExploratory data analysis using r
Exploratory data analysis using r
 
An overview of Python 2.7
An overview of Python 2.7An overview of Python 2.7
An overview of Python 2.7
 
A tour of Python
A tour of PythonA tour of Python
A tour of Python
 
4.ArraysInC.pdf
4.ArraysInC.pdf4.ArraysInC.pdf
4.ArraysInC.pdf
 
Introduction to matplotlib
Introduction to matplotlibIntroduction to matplotlib
Introduction to matplotlib
 
Lecture 02 visualization and programming
Lecture 02   visualization and programmingLecture 02   visualization and programming
Lecture 02 visualization and programming
 
2CPP06 - Arrays and Pointers
2CPP06 - Arrays and Pointers2CPP06 - Arrays and Pointers
2CPP06 - Arrays and Pointers
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
Modern C++
Modern C++Modern C++
Modern C++
 
hadoop introduce
hadoop introducehadoop introduce
hadoop introduce
 

Recently uploaded

Acorn Recovery: Restore IT infra within minutes
Acorn Recovery: Restore IT infra within minutesAcorn Recovery: Restore IT infra within minutes
Acorn Recovery: Restore IT infra within minutes
IP ServerOne
 
Obesity causes and management and associated medical conditions
Obesity causes and management and associated medical conditionsObesity causes and management and associated medical conditions
Obesity causes and management and associated medical conditions
Faculty of Medicine And Health Sciences
 
Getting started with Amazon Bedrock Studio and Control Tower
Getting started with Amazon Bedrock Studio and Control TowerGetting started with Amazon Bedrock Studio and Control Tower
Getting started with Amazon Bedrock Studio and Control Tower
Vladimir Samoylov
 
María Carolina Martínez - eCommerce Day Colombia 2024
María Carolina Martínez - eCommerce Day Colombia 2024María Carolina Martínez - eCommerce Day Colombia 2024
María Carolina Martínez - eCommerce Day Colombia 2024
eCommerce Institute
 
Eureka, I found it! - Special Libraries Association 2021 Presentation
Eureka, I found it! - Special Libraries Association 2021 PresentationEureka, I found it! - Special Libraries Association 2021 Presentation
Eureka, I found it! - Special Libraries Association 2021 Presentation
Access Innovations, Inc.
 
Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...
Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...
Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...
Orkestra
 
International Workshop on Artificial Intelligence in Software Testing
International Workshop on Artificial Intelligence in Software TestingInternational Workshop on Artificial Intelligence in Software Testing
International Workshop on Artificial Intelligence in Software Testing
Sebastiano Panichella
 
somanykidsbutsofewfathers-140705000023-phpapp02.pptx
somanykidsbutsofewfathers-140705000023-phpapp02.pptxsomanykidsbutsofewfathers-140705000023-phpapp02.pptx
somanykidsbutsofewfathers-140705000023-phpapp02.pptx
Howard Spence
 
Doctoral Symposium at the 17th IEEE International Conference on Software Test...
Doctoral Symposium at the 17th IEEE International Conference on Software Test...Doctoral Symposium at the 17th IEEE International Conference on Software Test...
Doctoral Symposium at the 17th IEEE International Conference on Software Test...
Sebastiano Panichella
 
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdfBonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
khadija278284
 
Media as a Mind Controlling Strategy In Old and Modern Era
Media as a Mind Controlling Strategy In Old and Modern EraMedia as a Mind Controlling Strategy In Old and Modern Era
Media as a Mind Controlling Strategy In Old and Modern Era
faizulhassanfaiz1670
 
Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...
Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...
Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...
OECD Directorate for Financial and Enterprise Affairs
 
Supercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdf
Supercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdfSupercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdf
Supercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdf
Access Innovations, Inc.
 
Announcement of 18th IEEE International Conference on Software Testing, Verif...
Announcement of 18th IEEE International Conference on Software Testing, Verif...Announcement of 18th IEEE International Conference on Software Testing, Verif...
Announcement of 18th IEEE International Conference on Software Testing, Verif...
Sebastiano Panichella
 
Bitcoin Lightning wallet and tic-tac-toe game XOXO
Bitcoin Lightning wallet and tic-tac-toe game XOXOBitcoin Lightning wallet and tic-tac-toe game XOXO
Bitcoin Lightning wallet and tic-tac-toe game XOXO
Matjaž Lipuš
 
0x01 - Newton's Third Law: Static vs. Dynamic Abusers
0x01 - Newton's Third Law:  Static vs. Dynamic Abusers0x01 - Newton's Third Law:  Static vs. Dynamic Abusers
0x01 - Newton's Third Law: Static vs. Dynamic Abusers
OWASP Beja
 

Recently uploaded (16)

Acorn Recovery: Restore IT infra within minutes
Acorn Recovery: Restore IT infra within minutesAcorn Recovery: Restore IT infra within minutes
Acorn Recovery: Restore IT infra within minutes
 
Obesity causes and management and associated medical conditions
Obesity causes and management and associated medical conditionsObesity causes and management and associated medical conditions
Obesity causes and management and associated medical conditions
 
Getting started with Amazon Bedrock Studio and Control Tower
Getting started with Amazon Bedrock Studio and Control TowerGetting started with Amazon Bedrock Studio and Control Tower
Getting started with Amazon Bedrock Studio and Control Tower
 
María Carolina Martínez - eCommerce Day Colombia 2024
María Carolina Martínez - eCommerce Day Colombia 2024María Carolina Martínez - eCommerce Day Colombia 2024
María Carolina Martínez - eCommerce Day Colombia 2024
 
Eureka, I found it! - Special Libraries Association 2021 Presentation
Eureka, I found it! - Special Libraries Association 2021 PresentationEureka, I found it! - Special Libraries Association 2021 Presentation
Eureka, I found it! - Special Libraries Association 2021 Presentation
 
Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...
Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...
Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...
 
International Workshop on Artificial Intelligence in Software Testing
International Workshop on Artificial Intelligence in Software TestingInternational Workshop on Artificial Intelligence in Software Testing
International Workshop on Artificial Intelligence in Software Testing
 
somanykidsbutsofewfathers-140705000023-phpapp02.pptx
somanykidsbutsofewfathers-140705000023-phpapp02.pptxsomanykidsbutsofewfathers-140705000023-phpapp02.pptx
somanykidsbutsofewfathers-140705000023-phpapp02.pptx
 
Doctoral Symposium at the 17th IEEE International Conference on Software Test...
Doctoral Symposium at the 17th IEEE International Conference on Software Test...Doctoral Symposium at the 17th IEEE International Conference on Software Test...
Doctoral Symposium at the 17th IEEE International Conference on Software Test...
 
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdfBonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
 
Media as a Mind Controlling Strategy In Old and Modern Era
Media as a Mind Controlling Strategy In Old and Modern EraMedia as a Mind Controlling Strategy In Old and Modern Era
Media as a Mind Controlling Strategy In Old and Modern Era
 
Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...
Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...
Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...
 
Supercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdf
Supercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdfSupercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdf
Supercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdf
 
Announcement of 18th IEEE International Conference on Software Testing, Verif...
Announcement of 18th IEEE International Conference on Software Testing, Verif...Announcement of 18th IEEE International Conference on Software Testing, Verif...
Announcement of 18th IEEE International Conference on Software Testing, Verif...
 
Bitcoin Lightning wallet and tic-tac-toe game XOXO
Bitcoin Lightning wallet and tic-tac-toe game XOXOBitcoin Lightning wallet and tic-tac-toe game XOXO
Bitcoin Lightning wallet and tic-tac-toe game XOXO
 
0x01 - Newton's Third Law: Static vs. Dynamic Abusers
0x01 - Newton's Third Law:  Static vs. Dynamic Abusers0x01 - Newton's Third Law:  Static vs. Dynamic Abusers
0x01 - Newton's Third Law: Static vs. Dynamic Abusers
 

Tools for research plotting

  • 2. Tools for Research Plotting 01 Mrs. Nimrita Koul School of Computing & IT
  • 3. Contents • Python Plots - matplotlib • R Plots 3
  • 4. Download Options for Python • www.python.org/downloads • https://www.anaconda.com/download/ • Installing Matplotlib • python -m pip install -U matplotlib • conda install -c conda-forge matplotlib 4
  • 5. matplotlib Dependencies • Python (>= 3.5) • FreeType (>= 2.3) • libpng (>= 1.2) • NumPy (>= 1.10.0) • setuptools • cycler (>= 0.10.0) • dateutil (>= 2.1) • kiwisolver (>= 1.0.0) • pyparsing 5
  • 6. 6 matplotlip Most used Python package for 2D- graphics pyplot provides a convenient interface to the matplotlib very quick Publication- quality figures in many formats
  • 7. 7
  • 9. 9
  • 10. 10
  • 11. 11
  • 12. 12
  • 13. 13
  • 14. 14
  • 15. 15
  • 16. 16 Other Types of Plots in matplotlib
  • 17. 17
  • 18. 18
  • 22. R Studio 22 • An IDE for R • Runs on Windows, Mac OS X and Linux • RStudio project has following folders for default content types:  code: source code  data: raw data, cleaned data  figures: charts and graphs  docs: documents and reports  models: analytics models
  • 23. R Plots • > cars <- c(1, 3, 6, 4, 9) • > plot(cars) 23
  • 24. • cars <- c(1, 3, 6, 4, 9) • # Graph cars using blue points overlayed by a line • plot(cars, type="o", col="blue") • # Create a title with a red, bold/italic font • title(main="Autos", col.main="red", font.main=4) 24
  • 25. • # Define 2 vectors • cars <- c(1, 3, 6, 4, 9) • trucks <- c(2, 5, 4, 5, 12) • # Graph cars using a y axis that ranges from 0 to 12 • plot(cars, type="o", col="blue", ylim=c(0,12)) • # Graph trucks with red dashed line and square points • lines(trucks, type="o", pch=22, lty=2, col="red") • # Create a title with a red, bold/italic font • title(main="Autos", col.main="red", font.main=4) 25
  • 26. 26
  • 27. • # Define 2 vectors • cars <- c(1, 3, 6, 4, 9) • trucks <- c(2, 5, 4, 5, 12) • # Calculate range from 0 to max value of cars and trucks • g_range <- range(0, cars, trucks) • # Graph autos using y axis that ranges from 0 to max value in cars or trucks vector. #Turn off axes and annotations (axis labels) so we can specify them our self • plot(cars, type="o", col="blue", ylim=g_range, axes=FALSE, ann=FALSE) • # Make x axis using Mon-Fri labels • axis(1, at=1:5, lab=c("Mon","Tue","Wed","Thu","Fri")) • # Make y axis with horizontal labels that display ticks at every 4 marks. #4*0:g_range[2] is equivalent to c(0,4,8,12). • axis(2, las=1, at=4*0:g_range[2]) 27
  • 28. • # Create box around plot • box() • # Graph trucks with red dashed line and square points • lines(trucks, type="o", pch=22, lty=2, col="red") • # Create a title with a red, bold/italic font • title(main="Autos", col.main="red", font.main=4) • # Label the x and y axes with dark green text • title(xlab="Days", col.lab=rgb(0,0.5,0)) • title(ylab="Total", col.lab=rgb(0,0.5,0)) • # Create a legend at (1, g_range[2]) that is slightly smaller # (cex) and uses the same #line colors and points used by the actual plots • legend(1, g_range[2], c("cars","trucks"), cex=0.8, • col=c("blue","red"), pch=21:22, lty=1:2); 28
  • 30. Plotting from a file• # Read car and truck values from tab-delimited autos.dat • autos_data <- read.table("C:/R/autos.dat", header=T, sep="t") • # Compute the largest y value used in the data (or we could # just use range again) • max_y <- max(autos_data) • # Define colors to be used for cars, trucks, suvs • plot_colors <- c("blue","red","forestgreen") • # Start PNG device driver to save output to figure.png • png(filename="C:/R/figure.png", height=295, width=300, bg="white") • # Graph autos using y axis that ranges from 0 to max_y. # Turn off axes and annotations (axis labels) so we can • # specify them ourself • plot(autos_data$cars, type="o", col=plot_colors[1], ylim=c(0,max_y), axes=FALSE, ann=FALSE) • # Make x axis using Mon-Fri labels • axis(1, at=1:5, lab=c("Mon", "Tue", "Wed", "Thu", "Fri")) • # Make y axis with horizontal labels that display ticks at every 4 marks. 4*0:max_y is equivalent to c(0,4,8,12). • axis(2, las=1, at=4*0:max_y) 30
  • 31. • # Create box around plot • box() • # Graph trucks with red dashed line and square points • lines(autos_data$trucks, type="o", pch=22, lty=2, col=plot_colors[2]) • # Graph suvs with green dotted line and diamond points • lines(autos_data$suvs, type="o", pch=23, lty=3, col=plot_colors[3]) • # Create a title with a red, bold/italic font • title(main="Autos", col.main="red", font.main=4) • # Label the x and y axes with dark green text • title(xlab= "Days", col.lab=rgb(0,0.5,0)) • title(ylab= "Total", col.lab=rgb(0,0.5,0)) • # Create a legend at (1, max_y) that is slightly smaller # (cex) and uses the same line colors and points used by • # the actual plots • legend(1, max_y, names(autos_data), cex=0.8, col=plot_colors, pch=21:23, lty=1:3); • • # Turn off device driver (to flush output to png) • dev.off() 31
  • 32. Plot from data in auto.dat 32
  • 33. Bar charts • # Read values from tab-delimited autos.dat • autos_data <- read.table("C:/R/autos.dat", header=T, sep="t") • # Graph cars with specified labels for axes. Use blue • # borders and diagnal lines in bars. • barplot(autos_data$cars, main="Cars", xlab="Days", • ylab="Total", names.arg= c("Mon","Tue","Wed","Thu","Fri"), • border="blue", density=c(10,20,30,40,50)) 33
  • 34. 34
  • 36. 36
  • 37. 37
  • 38. 38
  • 39. 39
  • 40. 40