from matplotlib.cbook import violin_stats rng = np.random.default_rng(19680801) data = rng.normal(size=(10, 3)) fig, (ax1, ax2) = plt.subplots(ncols=2, layout='constrained', figsize=(6.4, 3.5)) # Create the violin plot in one step ax1.violinplot(data) ax1.set_title('One Step') # Process the data and then create the violin plot vstats = violin_stats(data) ax2.violin(vstats) ax2.set_title('Two Steps')