0% found this document useful (0 votes)
7 views9 pages

Matplotlib Basics for Data Visualization

Uploaded by

sujanpavan57
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)
7 views9 pages

Matplotlib Basics for Data Visualization

Uploaded by

sujanpavan57
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

Data Visualization in Python

Introduction to Matplotlib

Your Name

October 11, 2025

Your Name Data Visualization in Python October 11, 2025 1/9


What is Matplotlib?

Core Python library for static, animated, and interactive visualizations.


Hierarchy: Figuring (canvas), Axes (plot region).
Interface mainly via pyplot as plt.

Your Name Data Visualization in Python October 11, 2025 2/9


Line Plot Example

import matplotlib . pyplot as plt


import numpy as np

x = np . linspace (0 , 10 , 100)
y = x **2

fig , ax = plt . subplots ()


ax . plot (x , y )
ax . set_xlabel ( ’X - axis ’)
ax . set_ylabel ( ’Y - axis ’)
ax . set_title ( ’y = x ^2 ’)

plt . show ()

Your Name Data Visualization in Python October 11, 2025 3/9


Line Plot Exercise

Plot y = sin x for 0 ≤ x ≤ 4π, labeling the axes properly.

Your Name Data Visualization in Python October 11, 2025 4/9


Bar Chart Example

courses = [ ’ CS ’ , ’ Mech ’ , ’ ECE ’ , ’ Civil ’]


students = [85 , 62 , 78 , 55]

fig , ax = plt . subplots ()


ax . bar ( courses , students )
ax . set_ylabel ( ’ Number of Students ’)
ax . set_title ( ’ Student Enrollment ’)

plt . show ()

Your Name Data Visualization in Python October 11, 2025 5/9


Bar Chart Exercise

Create a bar chart with months Jan-April and revenues 50, 65, 80, 72
respectively.

Your Name Data Visualization in Python October 11, 2025 6/9


Scatter Plot Example

x = np . random . rand (50) *100


y = np . random . rand (50) *100

fig , ax = plt . subplots ()


ax . scatter (x , y )
ax . set_title ( ’ Scatter Plot Example ’)

plt . show ()

Your Name Data Visualization in Python October 11, 2025 7/9


Scatter Plot Exercise

Plot a scatter plot showing a positive correlation plus some noise.

Your Name Data Visualization in Python October 11, 2025 8/9


Summary

Matplotlib basics: Figure and Axes.


Core plots: line, bar, scatter.
Exercises promote hands-on learning.
Advanced topics not covered here can be explored later.

Your Name Data Visualization in Python October 11, 2025 9/9

You might also like