0% found this document useful (0 votes)
2 views

Practical file work_Data Visualisation

The document provides Python programs for various data visualization techniques using Matplotlib, including bar graphs, line graphs, pie charts, scatter charts, and histograms. Each program includes a problem definition, sample data, and source code to create the respective visualizations. The examples cover mobile game ratings, clothing sales over months, monthly sales data, exam scores related to study hours, and student test score distributions.

Uploaded by

Khushi Seth
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Practical file work_Data Visualisation

The document provides Python programs for various data visualization techniques using Matplotlib, including bar graphs, line graphs, pie charts, scatter charts, and histograms. Each program includes a problem definition, sample data, and source code to create the respective visualizations. The examples cover mobile game ratings, clothing sales over months, monthly sales data, exam scores related to study hours, and student test score distributions.

Uploaded by

Khushi Seth
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

DATA VISUALISATION

Program # 17 BAR GRAPH


Problem definition: Write a program to represent the data on the
ratings of mobile games on bar chart. The sample data is given as:
Games:Pubg, FreeFire, MineCraft, GTA-V, Callofduty, FIFA 22.
Rating: 4.5,4.8,4.7,4.6,4.1,4.3

Source code:
import matplotlib.pyplot as plt
Games=['Pubg', 'FreeFire', 'MineCraft', 'GTA-V', 'Callofduty', 'FIFA 22']
Rating=[4.5,4.8,4.7,4.6,4.1,4.3]
plt.bar(Games,Rating,color=color=['green','orange','blue','black','red','pi
nk'])
plt.xlabel("Games")
plt.ylabel("Rating")
plt.title("Mobile app ratings")
plt.show()

Program # 18. LINE GRAPH


Problem definition:Consider the following data of a clothes store and
plot the data on the line chart and customize the chart as you wish:
Month Jeans T-Shirts Shirts
March 1500 4400 6500
April 3500 4500 5000
May 6500 5500 5800
June 6700 6000 6300
July 6000 5600 6200
August 6800 6300 4500

Source code:
import matplotlib.pyplot as plt
Months=['March', 'April', 'May','June', 'July', 'August']
Jeans=[1500,3500,6500,6700,6000,6800]
Tshirts=[4400,4500,5500,6000,5600,6300]
Shirts=[6500,5000,5800,6300,6200,4500]
plt.plot(Months,Jeans,c='b',marker="*",markersize="20",mec="r",mfc=
"g",linestyle="dotted")
plt.plot(Months,Tshirts,c='g',marker="D",markersize="20",mec="r",mfc
="g",linestyle="dashed")
plt.plot(Months,Shirts,c='r',marker="+",markersize="20",mec="g",mfc=
"b")
plt.xlabel("Months")
plt.ylabel("Apparels price")
plt.title("Prices of Apparels")
plt.show()

Program# 19 PIE CHART


Problem definition:Observe the given data for monthly sales of one of the
salesmen for 6 months. Plot them on the Pie chart.
Month January February March April May June
Sales 2500 2100 1700 3500 3000 3800
Apply the following customizations to the chart:
Give the title for the chart - "Monthly Sales of Salesman".

Source code:
import matplotlib.pyplot as plt

# Data for the pie chart


months = ["January", "February", "March", "April", "May", "June"]
sales = [2500, 2100, 1700, 3500, 3000, 3800]

# Plotting the pie chart


plt.figure(figsize=(8, 8))
plt.pie(sales, labels=months, autopct='%1.1f%%')
plt.title("Monthly Sales of Salesman")
plt.show()

Program#20 SCATTER CHART


Problem definition: Write a Python program to create a scatter chart
with the following dataset representing the relationship between hours
studied and exam scores:
Hours studied 1 2 3 4 5 6 7 8
Exam Score 50 55 65 70 75 80 85 90
● Plot the scatter chart using Hours Studied on the x-axis and
Exam Score on the y-axis.
● Add appropriate labels to the axes and a title to the chart.
● Display the scatter chart.
Source Code:
import matplotlib.pyplot as plt

# Dataset: Hours studied and corresponding exam scores


hours_studied = [1, 2, 3, 4, 5, 6, 7, 8]
exam_scores = [50, 55, 65, 70, 75, 80, 85, 90]

# Plotting the scatter chart


plt.scatter(hours_studied, exam_scores, color='blue', marker='o')

# Adding labels and title


plt.xlabel('Hours Studied')
plt.ylabel('Exam Score')
plt.title('Relationship Between Hours Studied and Exam Score')

# Display the scatter chart


plt.show()

Program#21 HISTOGRAM
Problem definition: Write a Python program to create a histogram with
the following dataset representing the distribution of students' scores
in a test:
Test Scores 85 78 92 88 76 95 89 72 84
● Plot a histogram to show the distribution of the test scores.
● Add appropriate labels to the x-axis and y-axis, and a title to the
chart.
● Customize the number of bins to properly visualize the data
distribution.
● Display the histogram.
Source code:
import matplotlib.pyplot as plt

# Dataset
test_scores = [85, 78, 92, 88, 76, 95, 89, 72, 84, 91]

# Plotting the histogram


plt.hist(test_scores, bins=5, edgecolor='black')

# Adding labels and title


plt.xlabel('Test Scores')
plt.ylabel('Number of Students')
plt.title('Distribution of Test Scores')

# Display the histogram


plt.show()

You might also like