0% found this document useful (0 votes)
33 views9 pages

Matplotlib Assignment Overview

This document provides code examples and explanations for creating different types of charts and graphs using the Matplotlib library in Python, including: 1. A bar graph comparing customer age and limit using DataFrames. 2. A histogram of customer ages using bins and custom labels/titles. 3. A line graph plotting city names against customer ages. 4. A scatter plot graphing customer age versus limit. 5. A pie chart displaying expenditure percentages for different departments with custom colors.

Uploaded by

Aditya patil
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views9 pages

Matplotlib Assignment Overview

This document provides code examples and explanations for creating different types of charts and graphs using the Matplotlib library in Python, including: 1. A bar graph comparing customer age and limit using DataFrames. 2. A histogram of customer ages using bins and custom labels/titles. 3. A line graph plotting city names against customer ages. 4. A scatter plot graphing customer age versus limit. 5. A pie chart displaying expenditure percentages for different departments with custom colors.

Uploaded by

Aditya patil
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Assignment Of Matplotlib

Name: -Prem Jakhate


Programme:- BBA-
IT(2021-24)
Div:-A
PRN:- 21030122075
Index Page No.
Bar Graph 1-3
Histogram 3-4
Line Graph 5
Scatter Plot 6
Pie chart 7-8

Page | 0
Bar Graph

#pip install matplotlib


import [Link] as plt
import pandas as pd
custdata = {
"Age": [34,47,56,71,80,],
"City":
["BANGALORE","CALCUTTA","COCHIN","BOMBAY","BANGALORE"],
"Limit": [500000,100000,200000,250000,370000],
"Segment": ["Self Employed","Salaried_MNC","Salaried_Pvt","Govt","Normal
Salary"]
}
# Create a DataFrame
df = [Link](custdata)
# Extract Age and Limit data for the bar graph
x = df["Age"]
y = df["Limit"]
# Create a bar graph
[Link](x, y, label='Customerdata', color='red')

Page | 1
# Set x and y axis labels
[Link]("Customer Age")
[Link]("Customer Limit")
# Set the title
[Link]("Customer Acquisition")
# Display the graph
[Link]()

Page | 2
1. Histogram
import [Link] as plt
import pandas as pd
#take individual Customer ages and range of ages
Cust_age=[76,71,34,47,56,70,26,67,79,54,51,29,16,25,52]
bins=[0,10,20,30,40,50,60,70,80]
#create histogram
[Link](Cust_age,bins,histtype='bar',rwidth=0.8,color='blue')
#set labels
[Link]('Customer age')

Page | 3
[Link]('No. of Customers')
[Link]('Customer Acquisition')
[Link]()
[Link]()

Page | 4
[Link]
import [Link] as plt
City=["BANGALORE","CALCUTTA","COCHIN","BOMBAY","DELHI"]
Age=[76,71,34,47,56]
[Link](City,Age,"blue")
[Link]("Customer Acquisition")
[Link]("City")
[Link]("Age")
[Link]()

Page | 5
4. Scatter plot
Age = [51,29,16,25,52]
Limit = [500000,100000,10000,10001,10002]
[Link](2, 2, 4)
[Link](x, y, label='Scatter Data', color='green')
[Link]('Age')
[Link]('Limit')
[Link]('Scatter Plot')
plt.tight_layout() # To ensure proper spacing
[Link]()

Page | 6
[Link] Chart
import [Link] as plt
#take expenditure of 4 departments
slices = [50,10,24,16]
#take department name
depts = ["Self Employed","Salaried_MNC","Salaried_Pvt","Govt"]
#take colour to each department
cols = ['red', 'green' , 'blue', 'yellow']
#create a pie chat
[Link](slices, labels=depts, colors=cols, startangle=90, autopct='%.1f%%')
[Link]("Customer Acquisition")
[Link]()
[Link]()

Page | 7
Page | 8

You might also like