In [1]:
import matplotlib.pyplot as plt
import scipy.stats
import numpy as np
%matplotlib inline
In [2]:
rvs_norm = scipy.stats.norm.rvs(loc=4.0, scale=2.0, size=500)
rvs_binom = scipy.stats.binom.rvs(n=10, p=0.4, size=500)
rvs_expon = scipy.stats.expon.rvs(loc=2.0, scale=5.0, size=500)
In [3]:
f,a = plt.subplots()
violins = a.violinplot((rvs_norm, rvs_binom, rvs_expon), showmeans=True, showmedians=True)
a.set_xticks((1.0, 2.0, 3.0))
a.set_xticklabels(('Norm', 'Binomial', 'Exponential'))
violins['bodies'][0].set_facecolor('orange')
violins['bodies'][0].set_edgecolor('black')
violins['cmedians']
Out[3]:
In [4]:
violins
Out[4]:
In [5]:
f,a = plt.subplots()
a.violinplot((rvs_norm, rvs_binom, rvs_expon), showmeans=True, showmedians=True, vert=False)
a.set_yticks((1.0, 2.0, 3.0))
a.set_yticklabels(('Norm', 'Binomial', 'Exponential'))
Out[5]: