def violinplot(vals, fillcolor='#1f77b4', rugplot=True):
 vals = np.asarray(vals, np.float)
 vals_min = calc_stats(vals)['min']
 vals_max = calc_stats(vals)['max']
 q1 = calc_stats(vals)['q1']
 q2 = calc_stats(vals)['q2']
 q3 = calc_stats(vals)['q3']
 d1 = calc_stats(vals)['d1']
 d2 = calc_stats(vals)['d2']
 pdf = scipy_stats.gaussian_kde(vals)
 xx = np.linspace(vals_min, vals_max, 100)
 yy = pdf(xx)
 max_pdf = np.max(yy)
 distance = (((2.0 * max_pdf) / 10) if rugplot else 0)
 plot_xrange = [(((- max_pdf) - distance) - 0.1), (max_pdf + 0.1)]
 plot_data = [make_half_violin((- yy), xx, fillcolor=fillcolor), make_half_violin(yy, xx, fillcolor=fillcolor), make_non_outlier_interval(d1, d2), make_quartiles(q1, q3), make_median(q2)]
 if rugplot:
  plot_data.append(make_violin_rugplot(vals, max_pdf, distance=distance, color=fillcolor))
 return (plot_data, plot_xrange)

def violinplot ( vals , fillcolor = '#1f77b4' , rugplot = True ) : vals = np . asarray ( vals , np . float ) vals_min = calc_stats ( vals ) [ 'min' ] vals_max = calc_stats ( vals ) [ 'max' ] q1 = calc_stats ( vals ) [ 'q1' ] q2 = calc_stats ( vals ) [ 'q2' ] q3 = calc_stats ( vals ) [ 'q3' ] d1 = calc_stats ( vals ) [ 'd1' ] d2 = calc_stats ( vals ) [ 'd2' ] pdf = scipy_stats . gaussian_kde ( vals ) xx = np . linspace ( vals_min , vals_max , 100 ) yy = pdf ( xx ) max_pdf = np . max ( yy ) distance = ( ( ( 2.0 * max_pdf ) / 10 ) if rugplot else 0 ) plot_xrange = [ ( ( ( - max_pdf ) - distance ) - 0.1 ) , ( max_pdf + 0.1 ) ] plot_data = [ make_half_violin ( ( - yy ) , xx , fillcolor = fillcolor ) , make_half_violin ( yy , xx , fillcolor = fillcolor ) , make_non_outlier_interval ( d1 , d2 ) , make_quartiles ( q1 , q3 ) , make_median ( q2 ) ] if rugplot : plot_data . append ( make_violin_rugplot ( vals , max_pdf , distance = distance , color = fillcolor ) ) return ( plot_data , plot_xrange )
make a violin plot of each dataset in the data sequence .