Created
August 10, 2012 05:08
-
-
Save mtakemiya/3311220 to your computer and use it in GitHub Desktop.
Beanplot Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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