Data Visualization With Matplotib
Data Visualization With Matplotib
VISUALIZATION
WITH MATPLOTIB
BY
POOJA S
I B.C.A
Agenda
Introduction
Matplotlib Library
Matplotlib Architecture
Pyplot
Data Visualization with Jupyter Notebook
Presentation title 3
The previous chapters covered the Python libraries
that are responsible for data processing, and this
chapter covers the libraries that take care of
visualization. You’ll first get a broad overview of
the matplotlib library, and then the chapter
concludes with the seaborn library, which extends
matplotlib with the representation of statistical
graphic elements.
5
DATA VISUALIZATION WITH MATPLOTIB
Installation
6
DATA VISUALIZATION WITH MATPLOTIB
CODE
If instead you have decided not to use the Anaconda
platform on your system, you can install matplotlib COMMAND
directly from the command console of your system
using the pip command
pip install matplotlib
7
DATA VISUALIZATION WITH MATPLOTIB
8
DATA VISUALIZATION WITH MATPLOTIB
9
DATA VISUALIZATION WITH MATPLOTIB
Artist Layer
10
DATA VISUALIZATION WITH MATPLOTIB
11
DATA VISUALIZATION WITH MATPLOTIB
from pylab import *
import matplotlib.pyplot as plt
import numpy as np
Pylab plot(x,y)
array([1,2,3,4])
and Pyplot Instead of
plt.plot()
np.array([1,2,3,4]
The pyplot package provides the classic Python interface for programming the
matplotlib library, has its own namespace, and requires the import of the NumPy
package separately. This approach is the one chosen for this book; it is the main topic of
this chapter; and it is used for the rest of the book. This approach is shared and approved
by most Python developers.
12
DATA VISUALIZATION WITH MATPLOTIB
Pyplot
13
The Plotting Window
15
DATA VISUALIZATION WITH MATPLOTIB
16
DATA VISUALIZATION WITH MATPLOTIB
plt.plot([1,2,3,4],[1,4,9,16])
17
Set the Properties of the Plot
• The size of the axes matches perfectly with the range of the input data
• There is neither a title nor axis labels
• There is no legend
• A Blue line connecting the points is drawn
Presentation title 18
Matplotlib and NumPy
import math
import numpy as np
t = np.arange(0,2.5,0.1)
y1 = np.sin(math.pi*t)
y2 = np.sin(math.pi*t+math.pi/2)
y3 = np.sin(math.pi*t-math.pi/2)
plt.plot(t,y1,'b*',t,y2,'g^',t,y3,'ys')
Presentation title 19
Thank you