Transform Your Data into Stunning Visuals with Matplotlib

Rina Mondal
2 min readJun 3, 2024

--

The matplotlib library in Python is a comprehensive library for creating static, animated, and interactive visualizations. It is widely used for plotting graphs and is particularly useful for creating publication-quality figures. Here is a basic overview of matplotlib along with some examples to help you get started.

Installation

You can install matplotlib using pip:

pip install matplotlib
#To import
import matplotlib.pyplot as plt # Here, plt is a nickname of matplotlib function

Basic Usage

Plots you can draw using Matplotlib:

  1. Line Plot: A type of plot that displays information as a series of data points called ‘markers’ connected by straight line segments. Line plots are useful for showing trends over time or other continuous data.
  2. Scatter Plot: A type of plot that shows the relationship between two numerical variables. Each point on the scatter plot represents an observation in the dataset.
  3. Bar Graph/ Bar Charts: A bar graph (or bar chart) is a graphical display of data using bars of different heights or lengths.
  4. Histogram: An estimate of the probability distribution of a continuous variable. A histogram is constructed by dividing the range of the data into bins (intervals) and counting the number of observations that fall into each bin.
  5. Box Plot: A standardized way of displaying the distribution of data based on a five-number summary: minimum, first quartile (Q1), median, third quartile (Q3), and maximum. Box plots are useful for identifying outliers and for comparing distributions between different datasets.
  6. Pie Plot: Used to display proportions of a whole, where each slice represents a category’s contribution to the total.

These are the basic plots which can be visualized using Matplotlib library. (Free complete explanations of these plots with coding is available in my YouTube channel. )

--

--

Rina Mondal

I have an 8 years of experience and I always enjoyed writing articles. If you appreciate my hard work, please follow me, then only I can continue my passion.