Violin Plot

Violin Plot :
import matplotlib.pyplot as plt
a = [1,2,35,9,10,15]
b = [5,20,12,25,7,38]
c= [3,7,18,22,14,31]
data = list([a, b, c])
plt.violinplot(data,showmeans=True, showmedians = True )
plt.show()
Customizing Violin Plot :
import matplotlib.pyplot as plt
a = [1,2,35,9,10,15]
b = [5,20,12,25,7,38]
c= [3,7,18,22,14,31]
data = list([a, b, c])
fig = plt.figure(figsize=(10,5))
plt.violinplot(data,showmeans=True, showmedians = True)
plt.legend()
plt.grid(True)
plt.xlabel("x")
plt.ylabel("y")
plt.show()
Adding Two Violin Plot : 

import matplotlib.pyplot as plt
a = [1,2,35,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.violinplot(data,showmeans=True, showmedians = True )
plt.legend()
plt.grid(True)
plt.xlabel("x")
plt.ylabel("y")

plt.subplot(1,2,2)
plt.violinplot(data1,showmeans=True,
showmedians = True )
plt.legend()
plt.grid(True)
plt.xlabel("x")
plt.ylabel("y")

plt.show()

Comments

Popular posts from this blog

Python Tokens

Pie Chart , Donut Plot, Area plot