EXPT NO 08
Title: Data Visualization using Python libraries: Matplotlib
Aim: To implement program for data visualization using matplotlib
Relevance:
Data visualization provides a good, organized pictorial representation of the data which makes
it easier to understand, observe, analyze.
Matplotlib is a comprehensive library for creating static, animated, and interactive visualizations
in Python. Matplotlib makes easy things easy and hard things possible.
Theory:-
Contents covered:
Data Visualization
Why need data visualization?
Benefit of Data Visualization
Creating different graphs ,
1. Line
2. Bar
3. Pie
4. Histogram
5. Scatter Plot
Link: https://www.javatpoint.com/matplotlib
Problem Statement:
Implement following Program:
1) Write a Python program to draw a line using given axis values taken from a
text file, with suitable label in the x axis, y axis and a title.
Test Data:
test.txt
12
24
31
The code snippet gives the output shown in the following screenshot:
2) 4. Write a Python program to draw line charts of the financial data of
Alphabet Inc. between October 3, 2016 to October 7, 2016.
Sample Financial data (fdata.csv):
Date,Open,High,Low,Close
10-03-16,774.25,776.065002,769.5,772.559998
10-04-16,776.030029,778.710022,772.890015,776.429993
10-05-16,779.309998,782.070007,775.650024,776.469971
10-06-16,779,780.47998,775.539978,776.859985
10-07-16,779.659973,779.659973,770.75,775.080017
The code snippet gives the output shown in the following screenshot:
3) Write a Python programming to display a bar chart of the popularity of
programming Languages.
Sample data:
Programming languages: Java, Python, PHP, JavaScript, C#, C++
Popularity: 22.2, 17.6, 8.8, 8, 7.7, 6.7
The code snippet gives the output shown in the following screenshot:
4) Write a Python program to create bar plot of scores by group and gender.
Use multiple X values on the same chart for men and women.
Sample Data:
Means (men) = (22, 30, 35, 35, 26)
Means (women) = (25, 32, 30, 35, 29)
The code snippet gives the output shown in the following screenshot:
5) Write a Python programming to create a pie chart of the popularity of
programming Languages.
Sample data:
Programming languages: Java, Python, PHP, JavaScript, C#, C++
Popularity: 22.2, 17.6, 8.8, 8, 7.7, 6.7
The code snippet gives the output shown in the following screenshot:
6) Write a Python program to draw a scatter plot comparing two subject
marks of Mathematics and Science. Use marks of 10 students.
Sample data:
Test Data:
math_marks = [88, 92, 80, 89, 100, 80, 60, 100, 80, 34]
science_marks = [35, 79, 79, 48, 100, 88, 32, 45, 20, 30]
marks_range = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
7) Draw histogram for following
you ask for the height of 250 people
You can read from the histogram that there are approximately:
2 people from 140 to 145cm
5 people from 145 to 150cm
15 people from 151 to 156cm
31 people from 157 to 162cm
46 people from 163 to 168cm
53 people from 168 to 173cm
45 people from 173 to 178cm
28 people from 179 to 184cm
21 people from 185 to 190cm
4 people from 190 to 195cm
Conclusion:-Write the crux of the experiment. Here crux means very important point,
complicated and again it should be understandable by you. Do not write conclusion like thus we
have studied the ……….. in python programming.