Program 18

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

PROGRAM 18:-

(A) Consider the table given below and write a program to plot a bar chart.

CITIES POPULATION

Delhi 23456123
Mumbai 20089104
Kolkata 18456192
Chennai 16898518]

Code:-

import matplotlib.pyplot as plt


cities=["Delhi","Mumbai","Kolkata","Chennai"]
popul=[23456123,20083104,18456192,16898518]
plt.bar(cities,popul)
plt.xlabel("cities")
plt.ylabel("Popul")
plt.show()

OUTPUT:-

(B) consider the same dataframe used in above question and write a program to plot a bar chart , each bar chart should be of
different color and width.

import matplotlib.pyplot as plt


cities=["Delhi","Mumbai","Kolkata","Chennai"]
popul=[23456123,20083104,18456192,16898518]
plt.bar(cities,popul,color=["r","b","g","k"],width=[0.8,0.7,0.6,0.5])
plt.xlabel("Cities")
plt.ylabel("Population")
plt.show()
output for program 19

You might also like