Skip to content

Instantly share code, notes, and snippets.

@mtakemiya
Created August 10, 2012 05:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mtakemiya/3311220 to your computer and use it in GitHub Desktop.
Save mtakemiya/3311220 to your computer and use it in GitHub Desktop.
Beanplot Example
import numpy as np
import matplotlib.pyplot as plt
import statsmodels.api as sm
shou = np.random.random(100)
chiku = np.log(shou)
bai = np.exp2(shou)
data=[shou, chiku, bai]
ll = ["shou (" + str(np.round(np.mean(shou),decimals=2))+")", "chiku (" + str(np.round(np.mean(chiku),decimals=2))+")", "bai (" + str(np.round(np.mean(bai),decimals=2))+")"]
plt.rcParams['figure.subplot.bottom'] = 0.23 # keep labels visible
fig = plt.figure()
fig.set_size_inches(15,9)
ax = fig.add_subplot(111)
ax.spines["right"].set_visible(False)
ax.spines["top"].set_visible(False)
for t in ax.xaxis.get_major_ticks():
t.tick2On = False
for t in ax.yaxis.get_major_ticks():
t.tick2On = False
sm.graphics.beanplot(data, ax=ax, labels=ll, plot_opts={'label_fontsize':'large', 'label_rotation':0,'violin_fc':'#AAAAFF'})
ax.set_xlabel("Data")
ax.set_ylabel("Value")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment