0% found this document useful (0 votes)
4 views15 pages

Matplotlib Notes

Matplotlib is a widely-used Python library for creating various types of visualizations, including static, animated, and interactive plots. It supports multiple plot types such as line, scatter, bar, histogram, pie, and 3D plots, making it essential for data science and scientific computing. Installation is straightforward via pip, and the library offers extensive formatting options for customization.

Uploaded by

Neetu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views15 pages

Matplotlib Notes

Matplotlib is a widely-used Python library for creating various types of visualizations, including static, animated, and interactive plots. It supports multiple plot types such as line, scatter, bar, histogram, pie, and 3D plots, making it essential for data science and scientific computing. Installation is straightforward via pip, and the library offers extensive formatting options for customization.

Uploaded by

Neetu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

Overview of Matplotlib

What is Matplotlib ?

Matplotlib is a popular Python library used for creating static, animated, and interactive
visualizations. It provides a comprehensive set of tools for generating plots, charts, and graphs,
making it widely used in data science, engineering, and scientific computing.

How to Install:

pip install matplotlib

Code Example:
Some commonly used methods:

Pairwise Data Plots:

Pairwise plots display relationships between multiple variables in a dataset. They show how
each pair of variables is related using scatter plots or other types.
Some widely used Plot types:

1. Plot:

It is used to create line plots. It connects data points with a line.​



Code example:

Formatting style methods for Plot(x,y):


2. Scatter Plot:

Scatter plots show individual data points as dots on a two-dimensional graph. They are useful
for visualizing relationships between two variables.​

Code example:

Formatting style methods for Scatter Plot:


3. Bar Plot:

Bar plots display data with rectangular bars, with the length of each bar proportional to the
value.


Code example:

Formatting style methods for Bar Plot:


4. Hist Plot:

A histogram plot is used to represent the distribution of data by dividing it into bins and
counting the number of data points that fall into each bin.


Code example:

Formatting style methods for Hist Plot:


5. Pie Plot:

A pie plot is used to represent categorical data in a circular format, where each category is
represented as a slice. The size of each slice is proportional to the quantity it represents.


Code example:

Formatting style methods for Pie Plot:


6. Stem Plot:

Stem plots display data as stems and leaves, with lines extending from a baseline to represent
values.


Code example:

Formatting style methods for Stem Plot:


7. Fill Between Plot:

The fill_between() function fills the area between two horizontal curves (typically, the
x-axis and a line).


Code example:

Formatting style methods for Fill Between Plot:

8. Stackplot Plot:
A stack plot displays multiple data series stacked on top of each other, typically used for
showing how parts contribute to the whole.


Code example:

Formatting style methods for Stack Plot:

9. Stairs Plot:
A stairs plot creates a stepped line plot where the lines change value at discrete steps.


Code example:

Formatting style methods for Stairs Plot:


3D Plotting:
Matplotlib also supports 3D plotting through the projection='3d. You can create 3D plots
such as scatter plots, surface plots, and wireframe plots.

1.​ 3D Scatter Plot


2.​ 3D Line Plot
3.​ 3D Surface Plot
Note for 3D Plots:
1.​ Enabling 3D Plotting with projection='3d':
a.​ By specifying projection='3d' when creating a subplot, you
enable 3D plotting in Matplotlib. This allows you to create various
types of 3D plots in the same figure.

2.​ Single Axis Object for Multiple 3D Plots:


a.​ You can use the same axis (ax) object to create various types of
3D plots, such as scatter plots, line plots, surface plots, and
wireframe plots. This makes it easy to manage and customize
different types of 3D visualizations in a single figure.

3.​ Interactive 3D Plots:


a.​ 3D plots can be interactive by default in environments like Jupyter
Notebooks, allowing users to rotate, zoom, and pan the plot for
better exploration of the data.

You might also like