0% found this document useful (0 votes)
26 views1 page

Practical File Program

The document contains Python code for creating three types of visualizations using Matplotlib. It includes a pie chart representing modes of transportation, a scatter chart visualizing rainfall data for Tamil Nadu from a CSV file, and a histogram displaying the heights of girls in class XII. Each visualization is accompanied by relevant labels, titles, and formatting to enhance clarity.

Uploaded by

sdg
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)
26 views1 page

Practical File Program

The document contains Python code for creating three types of visualizations using Matplotlib. It includes a pie chart representing modes of transportation, a scatter chart visualizing rainfall data for Tamil Nadu from a CSV file, and a histogram displaying the heights of girls in class XII. Each visualization is accompanied by relevant labels, titles, and formatting to enhance clarity.

Uploaded by

sdg
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
You are on page 1/ 1

# Write a program to create pie chart on the given data.

import matplotlib.pyplot as pl
labels = ["Car","Public Transit", "Walking", "Bicycle"]
sizes = [40,30,20,10]
colors=['green','c','lightgreen','yellow']
pl.figure(figsize=(6,6))
pl.pie(sizes,labels=labels,colors=colors,autopct='%1.1f%%')
pl.axis('Equal')
pl.title("Mode of Transportaion")
pl.show()

#Write a program to draw a scatter chart to visualize the comparative rainfall data for 12 months in
Tamil Nadu using the CSV file "rainfall.csv".

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
df=pd.read_csv("rainfall.csv")
x=df ['Months']
y=df['Rainfall']
plt.figure(figsize=(5,3))
plt.figure(figsize=(6,4))
colors = np.array([0, 10, 20, 30, 40, 45, 50, 60, 70, 80, 90, 100])
plt.scatter(x,y,c=colors,cmap='viridis')
plt.title("Rainfall data of Tamil Nadu", fontname='Calibri',
color='m',fontsize=16)
plt.xticks(rotation = 45)
plt.xlabel("Months", fontname='Calibri', color='b',fontsize=12)
plt.ylabel("Rainfall (cm)", fontname='Calibri', color='b',fontsize=12)
plt.show()

#Write a program to create histogram on the given data.

import matplotlib.pyplot as pl
a=[141, 145, 142, 147, 144, 148, 141, 142, 149, 144, 143, 149, 146,
141, 147, 142, 143]
pl.ylabel("Number of Girls")
pl.xlabel("Height")
pl.title(" Heights of Girls in class-XII")
pl.hist(a)
pl.show()

You might also like