Matplotlib bar and pie chart

 import matplotlib.pyplot as plt

import numpy as np


a = np.array(['Rubab','Ali','Shahbaz','Ayesha'])

b = np.array([95,89,75,40])


plt.title("Result")

plt.ylabel("marks")

plt.xlabel("Name of Students")

plt.bar(a,b, width = .5)

plt.show()


#pie chart

c = np.array([78,21,1])

names = ['Nitrogen', 'Oxygen', 'Other gases']

my_explode = [0, 0 ,0.1]

clr = ['#FFAA00','#E0D41E','#00AAFF']


plt.pie(c , labels = names, explode = my_explode, shadow = False, colors = clr)

plt.legend(title = 'Gases in air')

plt.show()

Comments

Popular posts from this blog

Amazon

Cyber Security

Xampp tutorial