Matplotlib Introduction

Matplotlib is the very powerful visualization library in Python which generates a beautiful variety of plots of data. To make the statistical inference, it is essential to visualize the data. Matplotlib library is one of the solutions to it. This entire tutorial explained various plot with example.

Types Of Plot

  • Bar Graph
  • Histogram
  • Scatter Plot
  • Area Plot
  • Pie Plot

.     .    .

Installing Matplotlib

The following command is used to install Matplotlib library in your local machine.

python -m pip install -U pip
python -m pip install -U matplotlib

.     .     .

Parts of a Figure

Figure:

A figure refers to the whole plotting picture. It keeps track of all the child such as Axes, label, Legend, title, etc. A figure can have multiple Axes. The simplest way to create a new figure is below.

fig = plt.figure()                      # an empty figure with no axes
fig, ax_lst = plt.subplots(2, 2)        # a figure with a 2x2 grid of Axes
fig.suptitle('No axes on this figure')  # Add a title so we know which it is

Axes:

Axes is the region of the plot with the data space. A figure can have multiple axes, but a axes object can only be in one figure. The axes contain two Axis for 2D plot and contain three Axis for the 3D plot. Each Axes has a title, an x-label and a y-label.

Axis:

Axis is the number-line like object. Axis manage to set the graph limits and generate the ticks. It also provides the label for ticks.

Artist:

Everything which you can see on the figure is an artist such as Figure, Axes, Axis, Text Object, etc. Artists are tied to an Axes. It cannot be shared by multiple Axes.

.     .     .

Pyplot Module

A Pyplot is the module of the Matplotlib library. The matplotlib.pyplot is a state-based interface to matplotlib. Pyplot is mainly designed to generate an interactive plot. This module provides lots of function such as different plotting function, plot decorative functions, etc.

Pylab Module

A Pylab is a convenience module that imports matplotlib.pyplot and numpy in a single namespace. The numpy library is used for mathematical calculations and matplotlib.pyplot package used for plotting.

.     .     .

Leave a Reply

Your email address will not be published. Required fields are marked *

Matplotlib Tutorials

Matplotlib – Graph Decoration

Matplotlib – subplot2grid

Matplolib – Twin Axes

Matplotlib – Axes Class

Matplotlib – Pyplot API

Matplotlib – Violin plot

Matplotlib – Box Plot

Matplotlib – Histogram

Matplotlib – Pie Chart

Matplotlib – Bar Plot

Matplotlib – Scatter plot

Matplotlib – Figure

Matplotlib – Subplot

Matplotlib – Plot