Data Visualization using Python, Matplotlib and Seaborn
Part 8 of "Data Analysis with Python: Zero to Pandas"
This tutorial series is a beginner-friendly introduction to programming and data analysis using the Python programming language. These tutorials take a practical and coding-focused approach. The best way to learn the material is to execute the code and experiment with it yourself. Check out the full series here:
- First Steps with Python and Jupyter
- A Quick Tour of Variables and Data Types
- Branching using Conditional Statements and Loops
- Writing Reusable Code Using Functions
- Reading from and Writing to Files
- Numerical Computing with Python and Numpy
- Analyzing Tabular Data using Pandas
- Data Visualization using Matplotlib & Seaborn
- Exploratory Data Analysis - A Case Study
This tutorial covers the following topics:
- Creating and customizing line charts using Matplotlib
- Visualizing relationships between two or more variables using scatter plots
- Studying distributions of variables using histograms & bar charts to
- Visualizing two-dimensional data using heatmaps
- Displaying images using Matplotlib's
- Plotting multiple Matplotlib and Seaborn charts in a grid
How to run the code
This tutorial is an executable Jupyter notebook hosted on Jovian. You can run this tutorial and experiment with the code examples in a couple of ways: using free online resources (recommended) or on your computer.
Option 1: Running using free online resources (1-click, recommended)
The easiest way to start executing the code is to click the Run button at the top of this page and select Run on Binder. You can also select "Run on Colab" or "Run on Kaggle", but you'll need to create an account on Google Colab or Kaggle to use these platforms.
Option 2: Running on your computer locally
To run the code on your computer locally, you'll need to set up Python, download the notebook and install the required libraries. We recommend using the Conda distribution of Python. Click the Run button at the top of this page, select the Run Locally option, and follow the instructions.
Jupyter Notebooks: This tutorial is a Jupyter notebook - a document made of cells. Each cell can contain code written in Python or explanations in plain English. You can execute code cells and view the results, e.g., numbers, messages, graphs, tables, files, etc., instantly within the notebook. Jupyter is a powerful platform for experimentation and analysis. Don't be afraid to mess around with the code & break things - you'll learn a lot by encountering and fixing errors. You can use the "Kernel > Restart & Clear Output" menu option to clear all outputs and start again from the top.
Data visualization is the graphic representation of data. It involves producing images that communicate relationships among the represented data to viewers. Visualizing data is an essential part of data analysis and machine learning. We'll use Python libraries Matplotlib and Seaborn to learn and apply some popular data visualization techniques. We'll use the words chart, plot, and graph interchangeably in this tutorial.
To begin, let's install and import the libraries. We'll use the
matplotlib.pyplot module for basic plots like line & bar charts. It is often imported with the alias
plt. We'll use the
seaborn module for more advanced plots. It is commonly imported with the alias
!pip install matplotlib seaborn --upgrade --quiet