44 lines
1.8 KiB
Python
44 lines
1.8 KiB
Python
import numpy as np
|
|
import matplotlib.pyplot as plt
|
|
from plotstyle import *
|
|
|
|
# normal distribution:
|
|
x = np.arange( -4.0, 4.0, 0.01 )
|
|
g = np.exp(-0.5*x*x)/np.sqrt(2.0*np.pi)
|
|
q = [ -0.67488, 0.0, 0.67488 ]
|
|
|
|
fig, ax = plt.subplots(figsize=cm_size(figure_width, 1.0*figure_height))
|
|
fig.subplots_adjust(**adjust_fs(bottom=2.7, top=0.1))
|
|
ax.set_xlabel('x')
|
|
ax.set_ylabel('Probability density p(x)')
|
|
ax.set_ylim(0.0, 0.46)
|
|
ax.set_yticks(np.arange(0.0, 0.45, 0.1))
|
|
ax.text(-1.2, 0.1, '25%', ha='center' )
|
|
ax.text(-0.35, 0.1, '25%', ha='center' )
|
|
ax.text(+0.35, 0.1, '25%', ha='center' )
|
|
ax.text(+1.2, 0.1, '25%', ha='center' )
|
|
ax.annotate('1. quartile',
|
|
xy=(-0.75, 0.2), xycoords='data',
|
|
xytext=(-1.7, 0.25), textcoords='data', ha='right',
|
|
arrowprops=dict(arrowstyle="->", relpos=(1.0,0.5),
|
|
connectionstyle="angle3,angleA=170,angleB=120") )
|
|
ax.annotate('3. quartile',
|
|
xy=(0.75, 0.17), xycoords='data',
|
|
xytext=(1.7, 0.22), textcoords='data', ha='left',
|
|
arrowprops=dict(arrowstyle="->", relpos=(0.0,0.5),
|
|
connectionstyle="angle3,angleA=10,angleB=70") )
|
|
ax.annotate('Median',
|
|
xy=(0.1, 0.3), xycoords='data',
|
|
xytext=(1.6, 0.35), textcoords='data', ha='left',
|
|
arrowprops=dict(arrowstyle="->", relpos=(0.0,0.5),
|
|
connectionstyle="angle3,angleA=10,angleB=40") )
|
|
ax.fill_between( x[x<q[0]], 0.0, g[x<q[0]], **fsCs)
|
|
ax.fill_between( x[(x>q[0])&(x<q[1])], 0.0, g[(x>q[0])&(x<q[1])], **fsBs)
|
|
ax.fill_between( x[(x>q[1])&(x<q[2])], 0.0, g[(x>q[1])&(x<q[2])], **fsDs)
|
|
ax.fill_between( x[x>q[2]], 0.0, g[x>q[2]], **fsEs)
|
|
ax.plot(x,g, **lsA)
|
|
ax.plot([0.0, 0.0], [0.0, 0.45], **lsMarker)
|
|
ax.plot([q[0], q[0]], [0.0, 0.4], **lsMarker)
|
|
ax.plot([q[2], q[2]], [0.0, 0.4], **lsMarker)
|
|
fig.savefig( 'quartile.pdf' )
|