Box Plot

Box Plot :
import matplotlib.pyplot as plt
a = [1,2,12,9,10,15]
b = [5,20,12,25,7,38]
c= [3,7,18,22,14,31]
data = list( [a, b, c])
plt.boxplot(data,showmeans=True)
plt. show()
Customizing Box Plot :

import matplotlib.pyplot as plt
a = [1,2,12,9,10,15]
b = [5,20,12,25,7,38]
c= [3,7,18,22,14,31]
data = list( [a, b, c])
plt.boxplot(data,showmeans=True)
plt.legend()
plt.grid(True)
plt. show()
Adding Two BoxPlot :

import matplotlib.pyplot as plt
a = [1,2,12,9,10,15]
b = [5,20,12,25,7,38]
c= [3,7,18,22,14,31]

a1 = [1,2,35,9,10,15]
b1= [5,20,12,25,7,38]
c1= [3,7,18,22,14,31]

data = list( [a, b, c])
data1 = list([a1, b1, c1])
fig = plt. figure(figsize=(10,5))

plt.subplot(1,2,1)
plt.boxplot(data , showmeans=True)
plt.legend()
plt. grid(True)
plt.xlabel("x")
plt. ylabel("y")

plt.subplot(1,2,2)
plt.boxplot(data1,showmeans=True)
plt.legend()
plt. grid(True)
plt.xlabel("x")
plt. ylabel("y")
plt.savefig("box.png")
plt. show()

Comments

Popular posts from this blog

Python Tokens

Pie Chart , Donut Plot, Area plot