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

PPTX
Data visualization using python
PDF
Up and Down the Python Data & Web Visualization Stack by Rob Story PyData SV ...
PPTX
24 hours later - FSharp Gotham 2015
PDF
RaspberryPiで作るガイガーカウンター
PPTX
python libray for data analytics seaborn[1].pptx
PPTX
python data science libray seaborn.pptx
PPTX
Seaborn & Plotly ................Intro.pptx
PDF
Machine learning
Data visualization using python
Up and Down the Python Data & Web Visualization Stack by Rob Story PyData SV ...
24 hours later - FSharp Gotham 2015
RaspberryPiで作るガイガーカウンター
python libray for data analytics seaborn[1].pptx
python data science libray seaborn.pptx
Seaborn & Plotly ................Intro.pptx
Machine learning

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

PDF
R Visualization Assignment
PPTX
Matplotlib - Python Plotting Library Description
PPTX
Matplotlib-Python-Plotting-Library(Edited).pptx
PDF
effectivegraphsmro1
PDF
Introduction to python
PDF
Data Analysis and Visualization using Python
PPTX
Tips and Tricks for Data Visualization in Python
PDF
Scientific Plotting in Python
PDF
Cristiano Politowski
PDF
Spelunking through JPEG with Racket (Sixth RacketCon)
PPT
Big Graph Analytics on Neo4j with Apache Spark
PDF
RAW Application_SAD Research Paper
PDF
Interaction designers vs algorithms
PPTX
TabPy Presentation
PDF
Looking at how Scratch and Python compare
PDF
Graphite tattle
PPTX
Which programming language to learn R or Python - MeasureCamp XII
PDF
Python at yhat (august 2013)
PDF
The post release technologies of Crysis 3 (Annotated Slides) - Stewart Needham
PDF
Donut chart in Revit with Dynamo
R Visualization Assignment
Matplotlib - Python Plotting Library Description
Matplotlib-Python-Plotting-Library(Edited).pptx
effectivegraphsmro1
Introduction to python
Data Analysis and Visualization using Python
Tips and Tricks for Data Visualization in Python
Scientific Plotting in Python
Cristiano Politowski
Spelunking through JPEG with Racket (Sixth RacketCon)
Big Graph Analytics on Neo4j with Apache Spark
RAW Application_SAD Research Paper
Interaction designers vs algorithms
TabPy Presentation
Looking at how Scratch and Python compare
Graphite tattle
Which programming language to learn R or Python - MeasureCamp XII
Python at yhat (august 2013)
The post release technologies of Crysis 3 (Annotated Slides) - Stewart Needham
Donut chart in Revit with Dynamo
Ad

More from Gaetan Lion (20)

PPTX
US inequality along numerous dimensions
PPTX
The US Fiscal Crisis Explained: Aging, Tax cuts, or Overspending
PPTX
DRU projections testing.pptx
PPTX
Climate Change in 24 US Cities
PPTX
Compact Letter Display (CLD). How it works
PPTX
CalPERS pensions vs. Social Security
PPTX
Recessions.pptx
PPTX
Inequality in the United States
PPTX
Housing Price Models
PDF
Global Aging.pdf
PPTX
Cryptocurrencies as an asset class
PPTX
Can you Deep Learn the Stock Market?
PPTX
Can Treasury Inflation Protected Securities predict Inflation?
PPTX
How overvalued is the Stock Market?
PPTX
The relationship between the Stock Market and Interest Rates
PPTX
Life expectancy
PPTX
Will Stock Markets survive in 200 years?
PPTX
Standardization
PPTX
Is Tom Brady the greatest quarterback?
PPT
Regularization why you should avoid them
US inequality along numerous dimensions
The US Fiscal Crisis Explained: Aging, Tax cuts, or Overspending
DRU projections testing.pptx
Climate Change in 24 US Cities
Compact Letter Display (CLD). How it works
CalPERS pensions vs. Social Security
Recessions.pptx
Inequality in the United States
Housing Price Models
Global Aging.pdf
Cryptocurrencies as an asset class
Can you Deep Learn the Stock Market?
Can Treasury Inflation Protected Securities predict Inflation?
How overvalued is the Stock Market?
The relationship between the Stock Market and Interest Rates
Life expectancy
Will Stock Markets survive in 200 years?
Standardization
Is Tom Brady the greatest quarterback?
Regularization why you should avoid them
Ad

Recently uploaded (20)

PPTX
01_intro xxxxxxxxxxfffffffffffaaaaaaaaaaafg
PPTX
oil_refinery_comprehensive_20250804084928 (1).pptx
PDF
Galatica Smart Energy Infrastructure Startup Pitch Deck
PPTX
Business Ppt On Nestle.pptx huunnnhhgfvu
PPTX
iec ppt-1 pptx icmr ppt on rehabilitation.pptx
PPTX
Introduction to Firewall Analytics - Interfirewall and Transfirewall.pptx
PPT
Reliability_Chapter_ presentation 1221.5784
PPTX
Introduction to machine learning and Linear Models
PDF
22.Patil - Early prediction of Alzheimer’s disease using convolutional neural...
PPTX
Business Acumen Training GuidePresentation.pptx
PPT
ISS -ESG Data flows What is ESG and HowHow
PPTX
Introduction-to-Cloud-ComputingFinal.pptx
PPTX
Data_Analytics_and_PowerBI_Presentation.pptx
PPTX
DISORDERS OF THE LIVER, GALLBLADDER AND PANCREASE (1).pptx
PPTX
climate analysis of Dhaka ,Banglades.pptx
PPTX
1_Introduction to advance data techniques.pptx
PPTX
Introduction to Knowledge Engineering Part 1
PDF
“Getting Started with Data Analytics Using R – Concepts, Tools & Case Studies”
PDF
Fluorescence-microscope_Botany_detailed content
PDF
Mega Projects Data Mega Projects Data
01_intro xxxxxxxxxxfffffffffffaaaaaaaaaaafg
oil_refinery_comprehensive_20250804084928 (1).pptx
Galatica Smart Energy Infrastructure Startup Pitch Deck
Business Ppt On Nestle.pptx huunnnhhgfvu
iec ppt-1 pptx icmr ppt on rehabilitation.pptx
Introduction to Firewall Analytics - Interfirewall and Transfirewall.pptx
Reliability_Chapter_ presentation 1221.5784
Introduction to machine learning and Linear Models
22.Patil - Early prediction of Alzheimer’s disease using convolutional neural...
Business Acumen Training GuidePresentation.pptx
ISS -ESG Data flows What is ESG and HowHow
Introduction-to-Cloud-ComputingFinal.pptx
Data_Analytics_and_PowerBI_Presentation.pptx
DISORDERS OF THE LIVER, GALLBLADDER AND PANCREASE (1).pptx
climate analysis of Dhaka ,Banglades.pptx
1_Introduction to advance data techniques.pptx
Introduction to Knowledge Engineering Part 1
“Getting Started with Data Analytics Using R – Concepts, Tools & Case Studies”
Fluorescence-microscope_Botany_detailed content
Mega Projects Data Mega Projects Data

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.