You are on page 1of 17

ARTIFICIAL INTELLIGENCE PROJECT

REPRESENTATION OF DIFFERENT
DATA SETS IN DIFFERENT
GRAPHICAL FORMATS

ANKIT
X-N
3
(Affiliated to Central Board of Secondary Education, New Delhi)
(Chettinad House, R.A. Puram, Chennai – 600 028)

ARTIFICIAL INTELLIGENCE [417]

Certified to be the Bonafide Record of work done by ____________ANKIT

______________________ of Std X Sec _N___ in the Computer Science Lab

of CHETTINAD VIDYASHRAM, CHENNAI, during the year 2022 – 2023.

Date: Teacher-in-charge

REGISTER NO.

Submitted for All India Secondary Practical Examination in A.I. held on

__________________________ at Chettinad Vidyashram, Chennai –

600 028.

Principal Internal Examiner External Examiner


ACKNOWLEDGEMENT

I would like to express my sincere thanks to Meena Aunty, Principal

Dr.Mrs. S. Amudha Lakshmi for their encouragement and support to

work on this Project. I am grateful to my Computer Science teacher

Mrs. CH.Sivakami and to the Computer Science department for the

constant guidance and support to complete the project.


INDEX

S.No Topic Page No.


.

1 Overview 5

2 Project Description 6

3 Programs 7

4 Outputs 12

5 Bibliography 17

Project Overview
Matplotlib
Matplotlib is a visualization library in Python for 2D plots of arrays. It is a
multi-platform data visualization library built on NumPy arrays. One of
the greatest benefits of visualization is that it allows us visual access to
huge amounts of data in easily digestible visuals.

Matplotlib comes with a wide variety of plots. Plots help to understand


trends, patterns, and to make correlations. They are instruments for
reasoning about quantitative information.

Applications of matplotlib

Matplotlib makes it easy to generate plots, line and scatter graphs,


histograms, boxplots, power spectra, bar charts, error charts, and other
kinds of plots, with just a few lines of code. Interactive Applications using
matplotlib teach us how to turn plots into fully interactive applications for
data exploration and information synthesis.

Graphs can be stylized and be more descriptive and communicable.

Installation

pip install matplotlib at the command prompt

Implementation

import matplotlib – in the program to draw graphs.


from matplotlib import pyplot as plt
Project Description

Representation of different data sets in


different graphical formats

This project is a compilation of different data sets in


different types of graphical representations like,

1. Pie-chart
2. Histogram
3. Line graph
4. Bar graph
5. Scatter plot

The program is developed using Python 3.8 and


matplotlib is utilized to display the data in graphical
formats.

Program 1 – Graphical Representation in


Pie Chart Format
import matplotlib
from matplotlib import pyplot as plt
## IPL winning teams is input into a list ; Pie chart is plotted;
percentage and labels are embedded
winners = [5,4,2,1,1,1,1];
my_labels = ['MI','CSK','KKR','RR','DCH','GT','SRH'];
my_colors = ['blue', 'yellow',
'purple','pink','cyan','green','orange']
plt.pie(winners,labels=my_labels,colors =
my_colors,autopct='%1.1f%%')
plt.title("Pie Chart - IPL Winners from 2008-2022")
plt.legend(title = "IPL Winning teams", loc="center left",
bbox_to_anchor=(1,0.5))
plt.show()

Program 2 – Graphical Representation in


Histogram Format
import matplotlib
from matplotlib import pyplot as plt
## runs scored by CSK in 2018 is fed to a list ; A histogram is
plotted.
runs_csk_2018=
[169,205,193,204,182,205,169,211,177,128,176,179,128,1
59,140,181];
mbins=[120,130,140,150,160,170,180,190,200,210,220,230
]
plt.hist(runs_csk_2018,bins=mbins,align='mid',color =
'yellow')
plt.ylabel("Count")
plt.xlabel("Runs scored by CSK in 2018")
plt.title("Histogram - CSK IPL 2018")
plt.grid()

plt.show()

Program 3 – Graphical Representation in


Line Graph Format
from matplotlib import pyplot as plt

x=[2009,2010,2011,2012,2013,2014,2015]
y=[0.039,0.048,0.054,0.047,0.052,0.042,0.051]
plt.plot(x,y,'g*-')
plt.grid(True)
plt.ylabel("Valuation in Billions")
plt.xlabel("Years")
plt.ylim(0.01,0.08)
plt.title("Brand Value(CSK)")
plt.show()

Program 4 – Graphical Representation in


Scatter plot Format
import matplotlib
from matplotlib import pyplot as plt

x=['2014','2015','2018','2019','2020','2021','2022']
y=[9,9,9,9,6,9,4]
plt.plot(x,y,'go')
plt.ylabel("Wins")
plt.xlabel("Year")
plt.title("CSK Year Wise wins - ")
plt.grid(True)

plt.show()

Program 5 – Graphical Representation in


Bar Graph Format
import matplotlib
from matplotlib import pyplot as plt
import numpy as np
w=0.4
x=["2018","2019","2020","2021","2022"]
y=[455,416,200,114,232]
plt.bar(x,y,w,align="center",color='yellow',label='Scores Per
Year')

plt.ylabel("Runs")
plt.xlabel("Year")
plt.title("Runs Scored by MS Dhoni in last 4 years")
plt.legend()
plt.show()

OUTPUT 1
OUTPUT 2
OUTPUT 3
OUTPUT 4
OUTPUT 5
Bibliography

1. CSK runs in 2018


https://www.mykhel.com/cricket/ipl-2018-chennai-fixtures-
results-tp58-s4/
2. IPL winners from 2008-2022
https://www.careerpower.in/ipl-winners-list.html
3. Pie chart reference code
https://www.w3schools.com/python/matplotlib_pie_charts.asp
4. Histogram reference code
https://www.w3schools.com/python/matplotlib_histograms.asp

You might also like