0% found this document useful (0 votes)
9 views3 pages

Unit5 Matplotlib Study Material MSBTESem5

This document provides an overview of data visualization using the Matplotlib library in Python, detailing its installation, basic plotting techniques, and various types of plots such as line, bar, scatter, histogram, and pie charts. It also covers customization of plots, exporting options, and the use of subplots, along with important questions for exam preparation. The content is aimed at students in the MSBTE Diploma Semester 5 Data Analytics course.

Uploaded by

yashshelar152
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)
9 views3 pages

Unit5 Matplotlib Study Material MSBTESem5

This document provides an overview of data visualization using the Matplotlib library in Python, detailing its installation, basic plotting techniques, and various types of plots such as line, bar, scatter, histogram, and pie charts. It also covers customization of plots, exporting options, and the use of subplots, along with important questions for exam preparation. The content is aimed at students in the MSBTE Diploma Semester 5 Data Analytics course.

Uploaded by

yashshelar152
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 ANALYTICS – UNIT 5: DATA VISUALIZATION USING PYTHON

(MATPLOTLIB)

Semester: 5 | Subject Code: 315326 | Scheme: K | Course Outcome: CO5 – Visualize Data Using Python
Library

1. Introduction to Matplotlib
Matplotlib is an open-source Python library used to create static, animated, and interactive visualizations in
Python. It is widely used for 2D plotting such as line, bar, scatter, and histogram charts. It integrates easily
with NumPy and Pandas, making it a key tool for data analytics.

Installation:
pip install matplotlib

Import:
import [Link] as plt

2. Basic Plotting with Matplotlib


The simplest type of plot is a line plot, showing data points connected by straight lines.
import [Link] as plt
import numpy as np

x = [Link]([0, 1, 2, 3])
y = [Link]([0, 1, 4, 9])

[Link](x, y)
[Link]()

With Annotations:
import [Link] as plt
import numpy as np

x = [Link]([0,1,2,3])
y = [Link]([0,1,4,9])

[Link](x, y, marker='o', linestyle='--', color='b')


[Link]('Simple x vs y Line Plot')
[Link]('x value')
[Link]('y = x^2')
[Link]()

3. Bar Chart
Used for comparing values between categories.
import [Link] as plt

categories = ['A','B','C','D']
values = [10, 20, 15, 25]

[Link](categories, values, color='skyblue')


[Link]('Bar Chart Example')
[Link]('Category')
[Link]('Value')
[Link]()

4. Scatter Plot
Displays relationship between two numeric variables.
import [Link] as plt
import numpy as np

x = [Link](50)
y = [Link](50)

[Link](x, y, color='red', marker='x')


[Link]('Scatter Plot Example')
[Link]('X Random')
[Link]('Y Random')
[Link]()

5. Histogram
Shows frequency distribution of numerical data.
import [Link] as plt
import numpy as np

data = [Link](1000)
[Link](data, bins=20, color='purple', edgecolor='black')
[Link]('Histogram of Normally Distributed Data')
[Link]('Value')
[Link]('Frequency')
[Link]()

6. Pie Chart
import [Link] as plt

labels = ['Apple','Banana','Cherry','Date']
sizes = [15,30,45,10]
explode = (0, 0.1, 0, 0)

[Link](sizes, explode=explode, labels=labels, autopct='%1.1f%%',


shadow=True, startangle=90)
[Link]('Fruit Proportion Pie Chart')
[Link]('equal')
[Link]()

7. Customizing Plots
You can modify titles, axis labels, legends, and figure size for clarity.
[Link](figsize=(8,5))
[Link](x, y, color='green', marker='o', linestyle='-', label='y = x^2')
[Link]('x value')
[Link]('y value')
[Link]('Customized Line Plot')
[Link]()
[Link](True)
[Link]()

8. Exporting Plots
Use savefig() to export plots in PNG, PDF, or SVG format.
[Link]('[Link]', dpi=300)
[Link]('[Link]')
[Link]()

9. Subplots
fig, axs = [Link](1,2, figsize=(10,4))
axs[0].plot(x, [Link](x))
axs[0].set_title('Sine Wave')
axs[1].plot(x, [Link](x))
axs[1].set_title('Cosine Wave')
plt.tight_layout()
[Link]()

10. Extra Important Questions for MSBTE Theory Exam


1. Define Matplotlib and explain its importance in data visualization.
2. Write steps to install and set up Matplotlib in Python.
3. List and explain any four types of plots with example code.
4. Explain how to customize plots (titles, labels, legends, figure size).
5. Write a Python program to display line, bar, and histogram plots in one figure using subplots.
6. What is the use of savefig()? List file formats supported by Matplotlib.
7. Explain how Matplotlib integrates with NumPy and Pandas.
8. Discuss exporting and saving visualizations with high resolution.
9. Explain the concept of axes, figure, and subplot with example.
10. Write a Python script to create and export a bar chart as PDF and PNG.

Topic Marks Weightage


Matplotlib Overview & Installation 2 Marks
Basic Plot Types 4 Marks
Customization & Exporting 4 Marks
Subplots & Integration 4 Marks

Prepared for: MSBTE Diploma Semester 5 – Data Analytics (315326)


Unit 5: Data Visualization using Python (Matplotlib)

You might also like