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

Plot Final

The document contains 5 programs that generate different types of charts from given data: Program 1 generates a line chart showing yearly profit of a company from 2014-2019. Program 2 generates a multiple line chart in the same figure to observe trends in monthly rainfall data for different zones in India from January to December. Program 3 generates a bar chart depicting total downloads of different apps. Program 4 generates a multiple bar chart using Pandas to plot score1 and score2 for different batsmen in a cricket match. Program 5 generates a histogram to show the distribution of ages of 80 participants in a game across 6 bins.

Uploaded by

Anoch Saju
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)
20 views

Plot Final

The document contains 5 programs that generate different types of charts from given data: Program 1 generates a line chart showing yearly profit of a company from 2014-2019. Program 2 generates a multiple line chart in the same figure to observe trends in monthly rainfall data for different zones in India from January to December. Program 3 generates a bar chart depicting total downloads of different apps. Program 4 generates a multiple bar chart using Pandas to plot score1 and score2 for different batsmen in a cricket match. Program 5 generates a histogram to show the distribution of ages of 80 participants in a game across 6 bins.

Uploaded by

Anoch Saju
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
You are on page 1/ 10

PROGRAM -1

Write a python program to generate LINE GRAPH with suitable title and labels.
Where x is the year of performance with values 2014,2015,2016,2017,2018
and 2019 and y axis shows the profit of a particular company in Rs.(Millions).

# A program to draw line chart showing Yearly profit of a Company


import matplotlib.pyplot as plt
x=[]
for i in range(2014,2020):
x.append(i)
y=[10000,5000,20000,17000,12000,7000]
plt.plot(x,y,color='r',marker='^', markeredgecolor='b', linestyle='dashed')
plt.grid()
plt.xlabel("Year ->", fontsize=13 ,color='blue')
plt.ylabel("Profit Rs. (in Millions)->", fontsize=13 ,color='blue')
plt.title(" Yearly Profit Analysis",color='r')
plt.show()
OUTPUT :-
PROGRAM -2
Given the following data of rainfall in different zones of India in mm for 12
months. Create MULTIPLE LINE CHART in a Figure to observe any trends from
Jan to Dec.
Zones Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
North 14 13 13 19 16 20 15 7 19 17 15 12
South 16 20 13 20 20 17 11 16 13 14 17 20

# To plot a line chart


import matplotlib.pyplot as plt
x = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']
y1 =[14,13,13,19,16,20,15,17,19,17,15,12]
y2=[16,20,13,20,20,17,11,16,13,14,17,20]
plt.plot(x,y1,linestyle='dashed',label='North Zone',marker='s', markeredgecolor='r')
plt.plot(x,y2,label='South Zone', marker='^', markeredgecolor='b')
plt.xlabel('Month->', fontsize=13, color='red')
plt.ylabel('Rainfall(in mm)->', fontsize=13, color='red')
plt.title('ZONE WISE RAINFALL ANALYSIS', color='blue')
plt.grid()
plt.legend()
plt.show()
OUTPUT :-
PROGRAM -3
Consider the data given below. Create a BAR CHART depicting the downloads
of the App.

App Name Total Downloads

VLC 197000
Spotify 209000
Tidal 414000
Netflix 196000
Kodi 272000
Hulu 311000
Audible 213000

# To plot a Bar Chart showing APP DOWNLOADS ANALYSIS


import matplotlib.pyplot as plt
apps = ['VLC','Spotify','Tidal', 'Netflix','Kodi','Hulu','Audible']
downloads =[197000,209000,414000,196000,272000, 311000,213000]
plt.bar (apps, downloads, color='g')
plt.xlabel ('Apps->', fontsize=12, color='green')
plt.ylabel ('Total Downloads->', fontsize=12, color='green')
plt.title ('APP DOWNLOADS ANALYSIS', color='black')
plt.grid()
plt.show()
OUTPUT :-
PROGRAM -4
Write a program in Python Pandas to create the following Data Frame
from a Dictionary. Plot a MULTIPLE BAR CHART to show the plotting of Score1
and Score2 for all Batsman.

Name Score1 Score2


1 M.S. Dhoni 95 80
2 Virat Kohli 85 92
3 Sachin 110 75
4 Kartik 75 80

# To plot multiple bar chart


import matplotlib.pyplot as plt
import pandas as pd
D={ 'Name':['M.S. Dhoni','Virat Kohli','Sachin','Kartik'],
'Score1':[90,65,70,80],
'Score2':[80,45,90,76],
}
df=pd.DataFrame(D,index=[1,2,3,4])
print(df)
df.plot(x='Name',y=['Score1','Score2'],kind='bar', rot=25)
plt.title('Cricket Score Analysis of Batsman', fontsize=17, color='r')
plt.xlabel('Name of Batsman',fontsize=14,color="r")
plt.ylabel('Scores',fontsize=14,color="r")
plt.legend()
plt.grid()
plt.show()
OUTPUT :-

Name Score1 Score2


1 M.S. Dhoni 90 80
2 Virat Kohli 65 45
3 Sachin 70 90
4 Kartik 80 76
PROGRAM -5
Given the ages of 80 participants in some game. Write a program to plot a
HISTOGRAM from given data with 6 bins of your choice.
Data=[9,10,11,13,13,15,16,17,18,19,21,23,23,23,24,24,25,25,25,25,25,26,26,
27,27,27,27,29,30,30,30,30,31,33,34,34,35,36,36,37,37,37,38,39,40,40,40,41,
42,43,43,39,30,31,32,33,34,35,36,37,38,39,36,37,38,40,41,42,43,44,45,50,51,
52,53,54,55,56,57,58]

# To plot a HISTOGRAM

import matplotlib.pyplot as plt


data=[ 9,10,11,13,13,15,16,17,18,19,21,23,23,23,24,24,25,25,25,25,25, 26, 26,27,27,
27, 27, 29,30,30,30,30,31,33,34,34,35,36, 36,37,37,37,38,39,40,40,40,41,
42,43,43,39,30,31,32,33,34,35,36,37,38,39,36,37,38,40,41,42,43,44,45,50
51,52,53,54,55,56,57,58 ]
b=[0,10,20,30,40,50,60]
plt.hist(data,bins=b,color='g',edgecolor='b')
plt.title("Participants of Game in different Age Groups",color='b', fontsize=16)
plt.xlabel("Age interval -->",fontsize=14, color='b')
plt.ylabel("No. of Participants -->",fontsize=14, color='b')
plt.show()
OUTPUT :-

You might also like