0% found this document useful (0 votes)
2 views4 pages

Exp2 Matplotlib

The document outlines an experiment focused on data visualization techniques using matplotlib in Python. It includes instructions for creating various plots such as line plots, bar charts, histograms, pie charts, and scatter plots. Each question provides code examples for generating specific visualizations based on given data.

Uploaded by

gowibe9937
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)
2 views4 pages

Exp2 Matplotlib

The document outlines an experiment focused on data visualization techniques using matplotlib in Python. It includes instructions for creating various plots such as line plots, bar charts, histograms, pie charts, and scatter plots. Each question provides code examples for generating specific visualizations based on given data.

Uploaded by

gowibe9937
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

Experiment 2

Aim: Implement data visualization techniques such as plotting, bar, histogram, pie etc using matplotlib.

In [2]: import numpy as np


import [Link] as plt

Question 1: Write a Python program to create a line plot showing temperature variation for 7 days.

In [4]: days = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']


temperature = [30, 32, 28, 35, 33, 29, 31]

[Link](days, temperature, marker='o')

[Link]('Temperature Variation Over 7 Days')


[Link]('Day')
[Link]('Temperature (°C)')

[Link]()

Question 2: Create a bar chart comparing marks of 5 students in a subject.

In [6]: students = ['Alice', 'Bob', 'Charlie', 'Diana', 'Eve']


marks = [78, 85, 62, 91, 74]

[Link](students, marks)

[Link]('Marks of 5 Students')
[Link]('Student')
[Link]('Marks')
[Link]()

Question 3: Generate 100 random numbers using NumPy and display them using a histogram. (USE:
data = [Link](100))

In [8]: data = [Link](100)

[Link](data, bins=10, color='purple', edgecolor='black')

[Link]('Histogram of 100 Random Numbers')


[Link]('Value')
[Link]('Frequency')

[Link]()
Question 4: Create a pie chart showing percentage distribution of students in 4 different branches.

In [10]: branches = ['CSE', 'ECE', 'ME', 'CE']


students = [40, 30, 15, 15]

[Link](students, labels=branches, autopct='%1.1f%%')


[Link]('Student Distribution Across Branches')

[Link]()
Question 5: Create a scatter plot and customize it by adding Title, X-axis label, Y-axis label, Different
color & Grid.

In [12]: x = [Link](0, 100, 50)


y = [Link](0, 100, 50)

[Link](x, y, color='orange', edgecolors='black')

[Link]('Scatter Plot of Random Data')


[Link]('X - Axis')
[Link]('Y - Axis')

[Link]()

You might also like