SlideShare a Scribd company logo
Data Visualization
Python matplotlib vs R ggplot2
Gaetan Lion, January 19, 2022
Introduction
A month ago I released a presentation “Is Tom Brady the greatest quarterback?”
https://www.slidesfinder.com/gaetan/is-tom-brady-the-greatest-quarterback-powerpoint-
presentation/4520.aspx
I decided to revisit this football stats data to compare the data visualization capabilities of R ggplot2
package vs. Python matplotlib & seaborn packages.
I focused on the number of touch downs over time for the 7 different quarterbacks included in this data
set.
And, I compare the two software using different types of graphs, including:
1) Time series graph of a single variable (the number of touch downs for one single quarterback);
2) Time series graph of multiple variables (including all 7 quarterbacks); and
3) Facet graphs when you generate a separate graph for each of the quarterbacks.
2
Time series graph for a single variable
3
4
Python R
On this one count, the two software are pretty even. Not much distinguishes one from the other. And, at the
margin, the coding in Python matplotlib was a little bit shorter and easier than in R ggplot2.
Time series graph for several variables
5
6
Python R
The look and feel of both graphs are pretty competitive. But, the R ggplot2 software generates automatically the
legend if you just call it. Within Python, within the legend function you have to name every single quarterbacks.
That is a pretty cumbersome procedure given that there are 7 of them.
7
Facet graphs
That’s where there is a huge difference between the two software. It was quite easy to do such facet
graphs in R. And, as you will see they were really pretty effective in conveying disaggregated
visualized data information.
In Python doing the equivalent graphs proved nearly impossible at my basic skill set level. This was
despite spending days in searching, googling, YouTubing on how to do those in Python. Every single
example I saw pretty much catered to scatter plots type graphs, not time series graphs. After a ton of
nearly random iterations, I was able to generate what are by comparison with R, extremely poor facet
graphs. I am sure one with much superior coding skills could generate beautiful Python facet time
series graphs. But, be warned. That is not an easy task. In this case, I clearly prefer R over Python.
8
R facet graph emphasizing the number of touch downs for each quarterback
That graph is pretty cool looking. And, is visually pretty informative. I use the related R graph script all the time
to have a better look at multi variables data. Also, the coding is really not that difficult.
9
Python facet graph emphasizing the number of touch downs for each quarterback
This Python graph is really pretty miserable looking. The minute I attempted to beautify it a bit with a grid, theme
color, etc. it generated all sorts of errors. Meanwhile, this same attributes (grid, color, etc.) did not generate any
errors when using the earlier and simpler graphs formats.
One with much better Python skills, I am sure could generate beautiful facet graphs in Python. But, be warned that
is not an easy task, especially for time series graphs. Python’s documentation for facet graphs is very much catered
to scatter plots, not simpler time series plots.
10
R facet graph emphasizing the longevity for each quarterback
Another successful R facet graph that clearly conveys the career longevity of each quarterback.
11
Python facet graph emphasizing the longevity for each quarterback
That graph is truly miserable. It lacks so much formatting as to render the quarterback’s longevity
record rather undifferentiable. The graph lacks differentiating line color and legend to identify the
different quarterbacks.
Even when giving it a close look at just a
couple of quarterbacks, the graphs look
terrible.
Line color, legends, and other attributes are
very challenging to generate within a facet
graph for time series. They were not possible
at my coding skill level.

More Related Content

Similar to Comparing R vs. Python for data visualization

GIS 5103 – Fundamentals of GISLecture 83D GIS.docx
GIS 5103 – Fundamentals of GISLecture 83D GIS.docxGIS 5103 – Fundamentals of GISLecture 83D GIS.docx
GIS 5103 – Fundamentals of GISLecture 83D GIS.docx
shericehewat
 
RAW Application_SAD Research Paper
RAW Application_SAD Research PaperRAW Application_SAD Research Paper
RAW Application_SAD Research Paper
Shirley Dash
 
Python at yhat (august 2013)
Python at yhat (august 2013)Python at yhat (august 2013)
Python at yhat (august 2013)
Austin Ogilvie
 

Similar to Comparing R vs. Python for data visualization (20)

GIS 5103 – Fundamentals of GISLecture 83D GIS.docx
GIS 5103 – Fundamentals of GISLecture 83D GIS.docxGIS 5103 – Fundamentals of GISLecture 83D GIS.docx
GIS 5103 – Fundamentals of GISLecture 83D GIS.docx
 
Data Analysis and Visualization using Python
Data Analysis and Visualization using PythonData Analysis and Visualization using Python
Data Analysis and Visualization using Python
 
Tips and Tricks for Data Visualization in Python
Tips and Tricks for Data Visualization in PythonTips and Tricks for Data Visualization in Python
Tips and Tricks for Data Visualization in Python
 
Scientific Plotting in Python
Scientific Plotting in PythonScientific Plotting in Python
Scientific Plotting in Python
 
Cristiano Politowski
Cristiano PolitowskiCristiano Politowski
Cristiano Politowski
 
Spelunking through JPEG with Racket (Sixth RacketCon)
Spelunking through JPEG with Racket (Sixth RacketCon)Spelunking through JPEG with Racket (Sixth RacketCon)
Spelunking through JPEG with Racket (Sixth RacketCon)
 
Big Graph Analytics on Neo4j with Apache Spark
Big Graph Analytics on Neo4j with Apache SparkBig Graph Analytics on Neo4j with Apache Spark
Big Graph Analytics on Neo4j with Apache Spark
 
RAW Application_SAD Research Paper
RAW Application_SAD Research PaperRAW Application_SAD Research Paper
RAW Application_SAD Research Paper
 
Interaction designers vs algorithms
Interaction designers vs algorithmsInteraction designers vs algorithms
Interaction designers vs algorithms
 
TabPy Presentation
TabPy PresentationTabPy Presentation
TabPy Presentation
 
Looking at how Scratch and Python compare
Looking at how Scratch and Python compareLooking at how Scratch and Python compare
Looking at how Scratch and Python compare
 
Graphite tattle
Graphite tattleGraphite tattle
Graphite tattle
 
Which programming language to learn R or Python - MeasureCamp XII
Which programming language to learn R or Python - MeasureCamp XIIWhich programming language to learn R or Python - MeasureCamp XII
Which programming language to learn R or Python - MeasureCamp XII
 
Python at yhat (august 2013)
Python at yhat (august 2013)Python at yhat (august 2013)
Python at yhat (august 2013)
 
The post release technologies of Crysis 3 (Annotated Slides) - Stewart Needham
The post release technologies of Crysis 3 (Annotated Slides) - Stewart NeedhamThe post release technologies of Crysis 3 (Annotated Slides) - Stewart Needham
The post release technologies of Crysis 3 (Annotated Slides) - Stewart Needham
 
Donut chart in Revit with Dynamo
Donut chart in Revit with DynamoDonut chart in Revit with Dynamo
Donut chart in Revit with Dynamo
 
Scaling graph investigations with Math, GPUs, & Experts
Scaling graph investigations with Math, GPUs, & ExpertsScaling graph investigations with Math, GPUs, & Experts
Scaling graph investigations with Math, GPUs, & Experts
 
Python vs. r for data science
Python vs. r for data sciencePython vs. r for data science
Python vs. r for data science
 
Have you met Julia?
Have you met Julia?Have you met Julia?
Have you met Julia?
 
How Graph Databases started the Multi Model revolution
How Graph Databases started the Multi Model revolutionHow Graph Databases started the Multi Model revolution
How Graph Databases started the Multi Model revolution
 

More from Gaetan Lion

More from Gaetan Lion (20)

DRU projections testing.pptx
DRU projections testing.pptxDRU projections testing.pptx
DRU projections testing.pptx
 
Climate Change in 24 US Cities
Climate Change in 24 US CitiesClimate Change in 24 US Cities
Climate Change in 24 US Cities
 
Compact Letter Display (CLD). How it works
Compact Letter Display (CLD).  How it worksCompact Letter Display (CLD).  How it works
Compact Letter Display (CLD). How it works
 
CalPERS pensions vs. Social Security
CalPERS pensions vs. Social SecurityCalPERS pensions vs. Social Security
CalPERS pensions vs. Social Security
 
Recessions.pptx
Recessions.pptxRecessions.pptx
Recessions.pptx
 
Inequality in the United States
Inequality in the United StatesInequality in the United States
Inequality in the United States
 
Housing Price Models
Housing Price ModelsHousing Price Models
Housing Price Models
 
Global Aging.pdf
Global Aging.pdfGlobal Aging.pdf
Global Aging.pdf
 
Cryptocurrencies as an asset class
Cryptocurrencies as an asset classCryptocurrencies as an asset class
Cryptocurrencies as an asset class
 
Can you Deep Learn the Stock Market?
Can you Deep Learn the Stock Market?Can you Deep Learn the Stock Market?
Can you Deep Learn the Stock Market?
 
Can Treasury Inflation Protected Securities predict Inflation?
Can Treasury Inflation Protected Securities predict Inflation?Can Treasury Inflation Protected Securities predict Inflation?
Can Treasury Inflation Protected Securities predict Inflation?
 
How overvalued is the Stock Market?
How overvalued is the Stock Market? How overvalued is the Stock Market?
How overvalued is the Stock Market?
 
The relationship between the Stock Market and Interest Rates
The relationship between the Stock Market and Interest RatesThe relationship between the Stock Market and Interest Rates
The relationship between the Stock Market and Interest Rates
 
Life expectancy
Life expectancyLife expectancy
Life expectancy
 
Will Stock Markets survive in 200 years?
Will Stock Markets survive in 200 years?Will Stock Markets survive in 200 years?
Will Stock Markets survive in 200 years?
 
Standardization
StandardizationStandardization
Standardization
 
Is Tom Brady the greatest quarterback?
Is Tom Brady the greatest quarterback?Is Tom Brady the greatest quarterback?
Is Tom Brady the greatest quarterback?
 
Regularization why you should avoid them
Regularization why you should avoid themRegularization why you should avoid them
Regularization why you should avoid them
 
Basketball the 3 pt game
Basketball the 3 pt gameBasketball the 3 pt game
Basketball the 3 pt game
 
Japan vs. US comparison on numerous dimensions
Japan vs. US comparison on numerous dimensionsJapan vs. US comparison on numerous dimensions
Japan vs. US comparison on numerous dimensions
 

Recently uploaded

一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
ewymefz
 
一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单
enxupq
 
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
nscud
 
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
nscud
 
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
ewymefz
 
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
vcaxypu
 
一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单
一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单
一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单
vcaxypu
 
Opendatabay - Open Data Marketplace.pptx
Opendatabay - Open Data Marketplace.pptxOpendatabay - Open Data Marketplace.pptx
Opendatabay - Open Data Marketplace.pptx
Opendatabay
 
一比一原版(TWU毕业证)西三一大学毕业证成绩单
一比一原版(TWU毕业证)西三一大学毕业证成绩单一比一原版(TWU毕业证)西三一大学毕业证成绩单
一比一原版(TWU毕业证)西三一大学毕业证成绩单
ocavb
 
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
ukgaet
 
Professional Data Engineer Certification Exam Guide  _  Learn  _  Google Clou...
Professional Data Engineer Certification Exam Guide  _  Learn  _  Google Clou...Professional Data Engineer Certification Exam Guide  _  Learn  _  Google Clou...
Professional Data Engineer Certification Exam Guide  _  Learn  _  Google Clou...
Domenico Conte
 
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
ewymefz
 

Recently uploaded (20)

一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
 
一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单
 
Supply chain analytics to combat the effects of Ukraine-Russia-conflict
Supply chain analytics to combat the effects of Ukraine-Russia-conflictSupply chain analytics to combat the effects of Ukraine-Russia-conflict
Supply chain analytics to combat the effects of Ukraine-Russia-conflict
 
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
 
How can I successfully sell my pi coins in Philippines?
How can I successfully sell my pi coins in Philippines?How can I successfully sell my pi coins in Philippines?
How can I successfully sell my pi coins in Philippines?
 
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
 
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
 
2024-05-14 - Tableau User Group - TC24 Hot Topics - Tableau Pulse and Einstei...
2024-05-14 - Tableau User Group - TC24 Hot Topics - Tableau Pulse and Einstei...2024-05-14 - Tableau User Group - TC24 Hot Topics - Tableau Pulse and Einstei...
2024-05-14 - Tableau User Group - TC24 Hot Topics - Tableau Pulse and Einstei...
 
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
 
一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单
一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单
一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单
 
Opendatabay - Open Data Marketplace.pptx
Opendatabay - Open Data Marketplace.pptxOpendatabay - Open Data Marketplace.pptx
Opendatabay - Open Data Marketplace.pptx
 
一比一原版(TWU毕业证)西三一大学毕业证成绩单
一比一原版(TWU毕业证)西三一大学毕业证成绩单一比一原版(TWU毕业证)西三一大学毕业证成绩单
一比一原版(TWU毕业证)西三一大学毕业证成绩单
 
Business update Q1 2024 Lar España Real Estate SOCIMI
Business update Q1 2024 Lar España Real Estate SOCIMIBusiness update Q1 2024 Lar España Real Estate SOCIMI
Business update Q1 2024 Lar España Real Estate SOCIMI
 
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
 
Using PDB Relocation to Move a Single PDB to Another Existing CDB
Using PDB Relocation to Move a Single PDB to Another Existing CDBUsing PDB Relocation to Move a Single PDB to Another Existing CDB
Using PDB Relocation to Move a Single PDB to Another Existing CDB
 
Professional Data Engineer Certification Exam Guide  _  Learn  _  Google Clou...
Professional Data Engineer Certification Exam Guide  _  Learn  _  Google Clou...Professional Data Engineer Certification Exam Guide  _  Learn  _  Google Clou...
Professional Data Engineer Certification Exam Guide  _  Learn  _  Google Clou...
 
Slip-and-fall Injuries: Top Workers' Comp Claims
Slip-and-fall Injuries: Top Workers' Comp ClaimsSlip-and-fall Injuries: Top Workers' Comp Claims
Slip-and-fall Injuries: Top Workers' Comp Claims
 
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
 
社内勉強会資料_LLM Agents                              .
社内勉強会資料_LLM Agents                              .社内勉強会資料_LLM Agents                              .
社内勉強会資料_LLM Agents                              .
 
Q1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year ReboundQ1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year Rebound
 

Comparing R vs. Python for data visualization

  • 1. Data Visualization Python matplotlib vs R ggplot2 Gaetan Lion, January 19, 2022
  • 2. Introduction A month ago I released a presentation “Is Tom Brady the greatest quarterback?” https://www.slidesfinder.com/gaetan/is-tom-brady-the-greatest-quarterback-powerpoint- presentation/4520.aspx I decided to revisit this football stats data to compare the data visualization capabilities of R ggplot2 package vs. Python matplotlib & seaborn packages. I focused on the number of touch downs over time for the 7 different quarterbacks included in this data set. And, I compare the two software using different types of graphs, including: 1) Time series graph of a single variable (the number of touch downs for one single quarterback); 2) Time series graph of multiple variables (including all 7 quarterbacks); and 3) Facet graphs when you generate a separate graph for each of the quarterbacks. 2
  • 3. Time series graph for a single variable 3
  • 4. 4 Python R On this one count, the two software are pretty even. Not much distinguishes one from the other. And, at the margin, the coding in Python matplotlib was a little bit shorter and easier than in R ggplot2.
  • 5. Time series graph for several variables 5
  • 6. 6 Python R The look and feel of both graphs are pretty competitive. But, the R ggplot2 software generates automatically the legend if you just call it. Within Python, within the legend function you have to name every single quarterbacks. That is a pretty cumbersome procedure given that there are 7 of them.
  • 7. 7 Facet graphs That’s where there is a huge difference between the two software. It was quite easy to do such facet graphs in R. And, as you will see they were really pretty effective in conveying disaggregated visualized data information. In Python doing the equivalent graphs proved nearly impossible at my basic skill set level. This was despite spending days in searching, googling, YouTubing on how to do those in Python. Every single example I saw pretty much catered to scatter plots type graphs, not time series graphs. After a ton of nearly random iterations, I was able to generate what are by comparison with R, extremely poor facet graphs. I am sure one with much superior coding skills could generate beautiful Python facet time series graphs. But, be warned. That is not an easy task. In this case, I clearly prefer R over Python.
  • 8. 8 R facet graph emphasizing the number of touch downs for each quarterback That graph is pretty cool looking. And, is visually pretty informative. I use the related R graph script all the time to have a better look at multi variables data. Also, the coding is really not that difficult.
  • 9. 9 Python facet graph emphasizing the number of touch downs for each quarterback This Python graph is really pretty miserable looking. The minute I attempted to beautify it a bit with a grid, theme color, etc. it generated all sorts of errors. Meanwhile, this same attributes (grid, color, etc.) did not generate any errors when using the earlier and simpler graphs formats. One with much better Python skills, I am sure could generate beautiful facet graphs in Python. But, be warned that is not an easy task, especially for time series graphs. Python’s documentation for facet graphs is very much catered to scatter plots, not simpler time series plots.
  • 10. 10 R facet graph emphasizing the longevity for each quarterback Another successful R facet graph that clearly conveys the career longevity of each quarterback.
  • 11. 11 Python facet graph emphasizing the longevity for each quarterback That graph is truly miserable. It lacks so much formatting as to render the quarterback’s longevity record rather undifferentiable. The graph lacks differentiating line color and legend to identify the different quarterbacks. Even when giving it a close look at just a couple of quarterbacks, the graphs look terrible. Line color, legends, and other attributes are very challenging to generate within a facet graph for time series. They were not possible at my coding skill level.