Thursday , December 2 2021
Home / Data Science / Introduction to Matplotlib

Introduction to Matplotlib

User Rating: Be the first one !
1. Introduction to Matplotlib

What Is Python Matplotlib?

  1. Matplotlib is a low level graph plotting library in python that serves as a visualization utility.
  2. Matplotlib was created by John D. Hunter.
  3. Matplotlib is open source and we can use it freely.

Matplotlib is mostly written in python, a few segments are written in C, Objective-C and Javascript for Platform compatibility. matplotlib.pyplot is a plotting library used for 2D graphics in python programming language. It can be used in python scripts, shell, web application servers and other graphical user interface toolkits.

Python Matplotlib : Types of Plots

There are various plots which can be created using python matplotlib. Some of them are listed below:


Documentation :

matplotlib.pyplot is a collection of command style functions that make matplotlib work like MATLAB. Each pyplot function makes some change to a figure: e.g., creates a figure, creates a plotting area in a figure, plots some lines in a plotting area, decorates the plot with labels, etc.

Matplotlib Instalation

In [ ]:
pip install matplotlib

Importing pyplot

  • from matplotlib import pyplot as plt
  • import matplotlib.pyplot as plt
In [2]:
import matplotlib

Available Style

In [3]:
import matplotlib.pyplot as plt

Format Strings

A format string consists of a part for color, marker and line:

fmt = '[marker][line][color]'


character description
. point marker
, pixel marker
o circle marker
v triangle_down marker
^ triangle_up marker
< triangle_left marker
> triangle_right marker
1 tri_down marker
2 tri_up marker
3 tri_left marker
4 tri_right marker
s square marker
p pentagon marker
* star marker
h hexagon1 marker
H hexagon2 marker
+ plus marker
x x marker
D diamond marker
d thin_diamond marker
vline marker
_ hline marker

Line Styles

character description
solid line style
dashed line style
-. dash-dot line style
: dotted line style
Example format strings:
b blue markers with default shape
or red circles
-g green solid line
dashed line with default color
^k: black triangle_up markers connected by a dotted line


The supported color abbreviations are the single letter codes

character color
b blue
g green
r red
c cyan
m magenta
y yellow
k black
w white

About Machine Learning

Check Also

Stack Plot using Matplotlib

6 Stack Plot Plot a Stack Plot using Matplotlib¶Stack Plots are used to visualize multiple …

Leave a Reply

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