SlideShare a Scribd company logo
The matplotlib Library
Haim Michael
October 14th
, 2020
All logos, trade marks and brand names used in this presentation belong
to the respective owners.
lifemichael
© 2008 Haim Michael 20150729
What is Matplotlib?
 Matplotlib is a library that allows us to create static,
animated, and interactive visualizations in Python.
© 2008 Haim Michael 20150729
Installing Matplotlib
 The simplest way to install matplotlib would be to install it
using the pip utility.
pip install matplotlib
© 2008 Haim Michael 20150729
The plot Function
 There are various ways to use the matplotlib library for
drawing diagrams. The simplest would be using the plot
function, that was defined inside the matplotlib.pyplot
module, passing over the x and the y coordinates.
© 2008 Haim Michael 20150729
The show Function
 Once completed, calling show will draw the diagram on the
screen.
import matplotlib.pyplot as plt
import numpy as np
plt.plot([1,2,3,4], [4,3,2,1], label='linear')
plt.legend()
plt.show()
© 2008 Haim Michael 20150729
The show Function
© 2008 Haim Michael 20150729
The Figure Class
 When instantiating matplotlib.figure.Figure class
we get an object that represents a window (or a page) on
which everything will be plotted.
© 2008 Haim Michael 20150729
The add_subplot Method
 We can invoke add_sublot on a Figure object in order to
add axes for plotting a diagram.
© 2008 Haim Michael 20150729
The add_subplot Method
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
ax = fig.add_subplot()
ax.scatter([1,2,3,4,5],[4,3,7,8,20])
plt.show()
© 2008 Haim Michael 20150729
The subplots Function
 We can invoke the sublots function that was defined in the
matplotlib.pyplot module and get a tuple that holds a
reference for a Figure object and a reference for an Axes
object.
© 2008 Haim Michael 20150729
The subplots Function
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0, 2, 20)
fig, ax = plt.subplots()
ax.plot(x, x, label='x=x')
ax.plot(x, x**2, label='x=x**2')
ax.plot(x, x**3, label='x=x**3')
ax.set_xlabel('x label')
ax.set_ylabel('y label')
ax.set_title("Simple Plot")
ax.legend()
plt.show()
© 2008 Haim Michael 20150729
The Interactive Mode
 We can turn on the interactive mode by calling the ion()
function.
 Doing so when using a Python console we will be able to
continue the execution of more statements in the Python
Console and while doing so, get to see the immediate
outcome.
© 2008 Haim Michael 20150729
The Interactive Mode
© 2008 Haim Michael 20150729
The plot() Function
 The plot() method that was defined inside the
matplotlib.pyplot module can be invoked in various
ways.
 The plot() method that was defined inside the
matplotlib.pyplot module can be invoked in various
ways.
© 2008 Haim Michael 20150729
The plot() Function
import matplotlib.pyplot as plt
import numpy as np
t = np.arange(0, 4, 0.1)
plt.plot(t, t, 'g--', t, t**2, 'bs', t, t**3, 'r^')
plt.show()
© 2008 Haim Michael 20150729
Q & A
 Thanks!
haim.michael@lifemichael.com
054-6655837
http://blog.lifemichael.com

More Related Content

PPTX
Python Seaborn Data Visualization
PDF
Python Matplotlib Tutorial | Matplotlib Tutorial | Python Tutorial | Python T...
PPTX
Introduction to matplotlib
PPTX
Visualization and Matplotlib using Python.pptx
PPTX
Python - Numpy/Pandas/Matplot Machine Learning Libraries
PPTX
Python pandas Library
PPTX
Introduction to numpy
PDF
Python NumPy Tutorial | NumPy Array | Edureka
Python Seaborn Data Visualization
Python Matplotlib Tutorial | Matplotlib Tutorial | Python Tutorial | Python T...
Introduction to matplotlib
Visualization and Matplotlib using Python.pptx
Python - Numpy/Pandas/Matplot Machine Learning Libraries
Python pandas Library
Introduction to numpy
Python NumPy Tutorial | NumPy Array | Edureka

What's hot (20)

PPTX
Python Scipy Numpy
PPT
Clustering
PDF
Introduction to Pandas and Time Series Analysis [PyCon DE]
PPTX
PDF
Introduction to Python for Data Science
PPTX
NumPy.pptx
PPTX
Scikit Learn intro
PPTX
PPT on Data Science Using Python
PDF
pandas - Python Data Analysis
PPTX
Data Analysis in Python-NumPy
PPT
Python Pandas
PPTX
Deep learning presentation
PDF
Intoduction to numpy
PPTX
Seaborn.pptx
PDF
Introduction to NumPy
PDF
Python - gui programming (tkinter)
ODP
Data Analysis in Python
PPTX
Packages In Python Tutorial
Python Scipy Numpy
Clustering
Introduction to Pandas and Time Series Analysis [PyCon DE]
Introduction to Python for Data Science
NumPy.pptx
Scikit Learn intro
PPT on Data Science Using Python
pandas - Python Data Analysis
Data Analysis in Python-NumPy
Python Pandas
Deep learning presentation
Intoduction to numpy
Seaborn.pptx
Introduction to NumPy
Python - gui programming (tkinter)
Data Analysis in Python
Packages In Python Tutorial
Ad

Similar to The matplotlib Library (20)

PPTX
Introduction to Pylab and Matploitlib.
PDF
UNit-III. part 2.pdf
PPTX
Matplotlib yayyyyyyyyyyyyyin Python.pptx
PPTX
matplotlib.pptxdsfdsfdsfdsdsfdsdfdsfsdf cvvf
PPTX
Python Visualization API Primersubplots
PPTX
Unit3-v1-Plotting and Visualization.pptx
PPTX
UNIT-5-II IT-DATA VISUALIZATION TECHNIQUES
PPTX
MatplotLib.pptx
PPTX
Unit III for data science engineering.pptx
PDF
matplotlib-installatin-interactive-contour-example-guide
PPTX
Matplotlib.pptx for data analysis and visualization
PDF
Use the Matplotlib, Luke @ PyCon Taiwan 2012
PPTX
Python for Machine Learning(MatPlotLib).pptx
PPTX
DDU Workshop Day-2 presentation (1).pptx
PDF
Matplotlib 簡介與使用
PPTX
Python Pyplot Class XII
PDF
Fashion E-Commerce: Using Computer Vision to Find Clothing that Fits Like a G...
PPTX
Introduction to Machine Learning by MARK
PPTX
Numerical_Analysis_Python_Presentation.pptx
PDF
Week002-Presentation.pptx-638674812983397395.pdf
Introduction to Pylab and Matploitlib.
UNit-III. part 2.pdf
Matplotlib yayyyyyyyyyyyyyin Python.pptx
matplotlib.pptxdsfdsfdsfdsdsfdsdfdsfsdf cvvf
Python Visualization API Primersubplots
Unit3-v1-Plotting and Visualization.pptx
UNIT-5-II IT-DATA VISUALIZATION TECHNIQUES
MatplotLib.pptx
Unit III for data science engineering.pptx
matplotlib-installatin-interactive-contour-example-guide
Matplotlib.pptx for data analysis and visualization
Use the Matplotlib, Luke @ PyCon Taiwan 2012
Python for Machine Learning(MatPlotLib).pptx
DDU Workshop Day-2 presentation (1).pptx
Matplotlib 簡介與使用
Python Pyplot Class XII
Fashion E-Commerce: Using Computer Vision to Find Clothing that Fits Like a G...
Introduction to Machine Learning by MARK
Numerical_Analysis_Python_Presentation.pptx
Week002-Presentation.pptx-638674812983397395.pdf
Ad

More from Haim Michael (20)

PDF
Prompt Engineering Jump Start [Free Meetup]
PDF
IntelliJ Debugging Essentials for Java Developers
PDF
The Visitor Classic Design Pattern [Free Meetup]
PDF
Typing in Python: Bringing Clarity, Safety and Speed to Your Code [Free Meetup]
PDF
Introduction to Pattern Matching in Java [Free Meetup]
PDF
Mastering The Collections in JavaScript [Free Meetup]
PDF
Beyond Java - Evolving to Scala and Kotlin
PDF
JavaScript Promises Simplified [Free Meetup]
PDF
Scala Jump Start [Free Online Meetup in English]
PDF
The MVVM Architecture in Java [Free Meetup]
PDF
Kotlin Jump Start Online Free Meetup (June 4th, 2024)
PDF
Anti Patterns
PDF
Virtual Threads in Java
PDF
MongoDB Design Patterns
PDF
Introduction to SQL Injections
PDF
Record Classes in Java
PDF
Microservices Design Patterns
PDF
Structural Pattern Matching in Python
PDF
Unit Testing in Python
PDF
OOP Best Practices in JavaScript
Prompt Engineering Jump Start [Free Meetup]
IntelliJ Debugging Essentials for Java Developers
The Visitor Classic Design Pattern [Free Meetup]
Typing in Python: Bringing Clarity, Safety and Speed to Your Code [Free Meetup]
Introduction to Pattern Matching in Java [Free Meetup]
Mastering The Collections in JavaScript [Free Meetup]
Beyond Java - Evolving to Scala and Kotlin
JavaScript Promises Simplified [Free Meetup]
Scala Jump Start [Free Online Meetup in English]
The MVVM Architecture in Java [Free Meetup]
Kotlin Jump Start Online Free Meetup (June 4th, 2024)
Anti Patterns
Virtual Threads in Java
MongoDB Design Patterns
Introduction to SQL Injections
Record Classes in Java
Microservices Design Patterns
Structural Pattern Matching in Python
Unit Testing in Python
OOP Best Practices in JavaScript

Recently uploaded (20)

PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Advanced IT Governance
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
[발표본] 너의 과제는 클라우드에 있어_KTDS_김동현_20250524.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Modernizing your data center with Dell and AMD
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Machine learning based COVID-19 study performance prediction
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Empathic Computing: Creating Shared Understanding
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Advanced IT Governance
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
[발표본] 너의 과제는 클라우드에 있어_KTDS_김동현_20250524.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Modernizing your data center with Dell and AMD
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Spectral efficient network and resource selection model in 5G networks
Per capita expenditure prediction using model stacking based on satellite ima...
20250228 LYD VKU AI Blended-Learning.pptx
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Machine learning based COVID-19 study performance prediction
NewMind AI Monthly Chronicles - July 2025
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Mobile App Security Testing_ A Comprehensive Guide.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Empathic Computing: Creating Shared Understanding

The matplotlib Library

  • 1. The matplotlib Library Haim Michael October 14th , 2020 All logos, trade marks and brand names used in this presentation belong to the respective owners. lifemichael
  • 2. © 2008 Haim Michael 20150729 What is Matplotlib?  Matplotlib is a library that allows us to create static, animated, and interactive visualizations in Python.
  • 3. © 2008 Haim Michael 20150729 Installing Matplotlib  The simplest way to install matplotlib would be to install it using the pip utility. pip install matplotlib
  • 4. © 2008 Haim Michael 20150729 The plot Function  There are various ways to use the matplotlib library for drawing diagrams. The simplest would be using the plot function, that was defined inside the matplotlib.pyplot module, passing over the x and the y coordinates.
  • 5. © 2008 Haim Michael 20150729 The show Function  Once completed, calling show will draw the diagram on the screen. import matplotlib.pyplot as plt import numpy as np plt.plot([1,2,3,4], [4,3,2,1], label='linear') plt.legend() plt.show()
  • 6. © 2008 Haim Michael 20150729 The show Function
  • 7. © 2008 Haim Michael 20150729 The Figure Class  When instantiating matplotlib.figure.Figure class we get an object that represents a window (or a page) on which everything will be plotted.
  • 8. © 2008 Haim Michael 20150729 The add_subplot Method  We can invoke add_sublot on a Figure object in order to add axes for plotting a diagram.
  • 9. © 2008 Haim Michael 20150729 The add_subplot Method import matplotlib.pyplot as plt import numpy as np fig = plt.figure() ax = fig.add_subplot() ax.scatter([1,2,3,4,5],[4,3,7,8,20]) plt.show()
  • 10. © 2008 Haim Michael 20150729 The subplots Function  We can invoke the sublots function that was defined in the matplotlib.pyplot module and get a tuple that holds a reference for a Figure object and a reference for an Axes object.
  • 11. © 2008 Haim Michael 20150729 The subplots Function import matplotlib.pyplot as plt import numpy as np x = np.linspace(0, 2, 20) fig, ax = plt.subplots() ax.plot(x, x, label='x=x') ax.plot(x, x**2, label='x=x**2') ax.plot(x, x**3, label='x=x**3') ax.set_xlabel('x label') ax.set_ylabel('y label') ax.set_title("Simple Plot") ax.legend() plt.show()
  • 12. © 2008 Haim Michael 20150729 The Interactive Mode  We can turn on the interactive mode by calling the ion() function.  Doing so when using a Python console we will be able to continue the execution of more statements in the Python Console and while doing so, get to see the immediate outcome.
  • 13. © 2008 Haim Michael 20150729 The Interactive Mode
  • 14. © 2008 Haim Michael 20150729 The plot() Function  The plot() method that was defined inside the matplotlib.pyplot module can be invoked in various ways.  The plot() method that was defined inside the matplotlib.pyplot module can be invoked in various ways.
  • 15. © 2008 Haim Michael 20150729 The plot() Function import matplotlib.pyplot as plt import numpy as np t = np.arange(0, 4, 0.1) plt.plot(t, t, 'g--', t, t**2, 'bs', t, t**3, 'r^') plt.show()
  • 16. © 2008 Haim Michael 20150729 Q & A  Thanks! [email protected] 054-6655837 http://blog.lifemichael.com