updated plots of the data analysis chapters

This commit is contained in:
2020-01-14 23:38:16 +01:00
parent 75aa46d71c
commit 9769d5e94f
18 changed files with 226 additions and 272 deletions

View File

@@ -1,8 +1,7 @@
import numpy as np
import matplotlib.pyplot as plt
from plotstyle import *
plt.xkcd()
fig = plt.figure( figsize=(6,3.5) )
rng = np.random.RandomState(637281)
nsamples = 100
@@ -25,11 +24,8 @@ for i in range(nresamples) :
musrs.append(np.mean(rng.randn(nsamples)))
hmusrs, _ = np.histogram(musrs, bins, density=True)
ax = fig.add_subplot(1, 1, 1)
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
ax.yaxis.set_ticks_position('left')
ax.xaxis.set_ticks_position('bottom')
fig, ax = plt.subplots(figsize=cm_size(figure_width, 1.2*figure_height))
fig.subplots_adjust(**adjust_fs(left=4.0, bottom=2.7, right=1.5))
ax.set_xlabel('Mean')
ax.set_xlim(-0.4, 0.4)
ax.set_ylabel('Probability density')
@@ -45,9 +41,7 @@ ax.annotate('bootstrap\ndistribution',
xytext=(0.25, 4), textcoords='data',
arrowprops=dict(arrowstyle="->", relpos=(0.0,0.5),
connectionstyle="angle3,angleA=20,angleB=60") )
ax.bar(bins[:-1]-0.25*db, hmusrs, 0.5*db, color='r')
ax.bar(bins[:-1]+0.25*db, hmus, 0.5*db, color='b')
ax.bar(bins[:-1]-0.25*db, hmusrs, 0.5*db, **fsB)
ax.bar(bins[:-1]+0.25*db, hmus, 0.5*db, **fsA)
plt.tight_layout()
plt.savefig('bootstrapsem.pdf')
#plt.show();

View File

@@ -1,9 +1,8 @@
import numpy as np
import scipy.stats as st
import matplotlib.pyplot as plt
from plotstyle import *
plt.xkcd()
fig = plt.figure( figsize=(6,3.5) )
rng = np.random.RandomState(637281)
# generate correlated data:
@@ -36,33 +35,28 @@ print('Measured correlation coefficient %.2f is at %.4f percentile of bootstrap'
rp, ra = st.pearsonr(x, y)
print('Measured correlation coefficient %.2f is at %.4f percentile of test' % (rp, ra))
ax = fig.add_subplot(1, 1, 1)
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
ax.yaxis.set_ticks_position('left')
ax.xaxis.set_ticks_position('bottom')
fig, ax = plt.subplots(figsize=cm_size(figure_width, 1.2*figure_height))
fig.subplots_adjust(**adjust_fs(left=4.0, bottom=2.7, right=0.5, top=1.0))
ax.annotate('Measured\ncorrelation\nis significant!',
xy=(rd, 1.1), xycoords='data',
xytext=(rd, 2.2), textcoords='data', ha='left',
arrowprops=dict(arrowstyle="->", relpos=(0.2,0.0),
connectionstyle="angle3,angleA=10,angleB=80") )
connectionstyle="angle3,angleA=10,angleB=80") )
ax.annotate('95% percentile',
xy=(0.14, 0.9), xycoords='data',
xytext=(0.2, 4.0), textcoords='data', ha='left',
arrowprops=dict(arrowstyle="->", relpos=(0.1,0.0),
connectionstyle="angle3,angleA=30,angleB=70") )
connectionstyle="angle3,angleA=30,angleB=70") )
ax.annotate('Distribution of\nuncorrelated\nsamples',
xy=(-0.08, 3.6), xycoords='data',
xytext=(-0.22, 5.0), textcoords='data', ha='left',
arrowprops=dict(arrowstyle="->", relpos=(0.5,0.0),
connectionstyle="angle3,angleA=150,angleB=100") )
ax.bar(b[:-1], h, width=b[1]-b[0], color='#ffff66')
ax.bar(b[:-1][b[:-1]>=rq], h[b[:-1]>=rq], width=b[1]-b[0], color='#ff9900')
ax.plot( [rd, rd], [0, 1], 'b', linewidth=4 )
connectionstyle="angle3,angleA=150,angleB=100") )
ax.bar(b[:-1], h, width=b[1]-b[0], **fsC)
ax.bar(b[:-1][b[:-1]>=rq], h[b[:-1]>=rq], width=b[1]-b[0], **fsB)
ax.plot( [rd, rd], [0, 1], **lsA)
ax.set_xlim(-0.25, 0.35)
ax.set_xlabel('Correlation coefficient')
ax.set_ylabel('Probability density of H0')
plt.tight_layout()
plt.savefig('permutecorrelation.pdf')
#plt.show();