matplotlib bar chart

 # Creating a simple barchart using matplotlib


# importing the required module 

import matplotlib.pyplot as plt 


# plotting the x and y axis values for two sets of data


plt.bar([1,2,3,4,5,6,7],[7.1,9.4,10.6,12.5,11.5,10.9,9.8], label="Chennai",width=.25)


plt.bar([1.25,2.25,3.25,4.25,5.25,6.25,7.25],[8.1,10.4,9.6,8.5,10.5,8.9,7.8], label="Kancheepuram",width=.25) 


# Naming the axes and setting the legends

plt.legend()

plt.xlabel('Days')

plt.ylabel('Rainfall (mm)')


# Graph title

plt.title('Rainfall')


# Display the graph

plt.show()

"""

Output



"""


No comments:

Post a Comment

Don't be a silent reader...
Leave your comments...

Anu