Matplotlib and Seaborn PDF
Matplotlib and Seaborn PDF
Matplotlib
What is Matplotlib?
Data visualization involves exploring data through visual
representations.
The matplotlib package helps you make visually appealing
representations of the data you’re working with.
Matplotlib is extremely flexible
Following examples will help you get started with a few simple
visualizations.
Installing Matplotlib
Matplotlib runs on all systems, but setup is slightly different
depending on your OS.
If the minimal instructions here don’t work for you, see the more
detailed instructions at http://ehmatthes.github.io/pcc/.
You should also consider installing the Anaconda distribution of
Python from https://continuum.io/downloads/, which includes
matplotlib.
Installing Matplotlib
matplotlib on Linux
$ sudo apt-get install python3-matplotlib
matplotlib
matplotlib on OS X
Start a terminal session and enter import matplotlib to see if it’s already
installed on your system.
If not, try this command: $ pip install --user matplotlib
matplotlib on Windows
You first need to install Visual Studio, which you can do from
https://dev.windows.com/. The Community edition is free.
Then go to https://pypi.python.org/pypi/matplotlib/ or
http://www.lfd.uic.edu/~gohlke/pythonlibs/#matplotlib and download an
appropriate installer file.
Since we are using anaconda it might be there.
Line graphs and scatter plot
Making a line graph
import matplotlib.pyplot as plt
x_values = [0, 1, 2, 3, 4, 5]
squares = [0, 1, 4, 9, 16, 25]
plt.plot(x_values, squares)
plt.show()
Line graphs and scatter plot
Making a scatter plot
The scatter() function takes a list of x values and a list of y values,
and a variety of optional arguments. The s=10 argument controls
the size of each point.
Relational plots: This plot is used to understand the relation between two
variables.
Categorical plots: This plot deals with categorical variables and how they can be
visualized.
Distribution plots: This plot is used for examining univariate and bivariate
distributions
Regression plots: The regression plots in seaborn are primarily intended to add
a visual guide that helps to emphasize patterns in a dataset during exploratory data
analyses.
Matrix plots: A matrix plot is an array of scatterplots.
Multi-plot grids: It is an useful approach is to draw multiple instances of the
same plot on different subsets of the dataset.
Go to document