import numpy as np
import matplotlib.pyplot as plt

# roll the die:
rng = np.random.RandomState(57281)
x1 = rng.random_integers( 1, 6, 100 )
x2 = rng.random_integers( 1, 6, 500 )
bins = np.arange(0.5, 7, 1.0)

plt.xkcd()

fig = plt.figure( figsize=(6,3) )
ax = fig.add_subplot( 1, 2, 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')
ax.set_xlim(0, 7)
ax.set_xticks( range(1, 7) )
ax.set_xlabel( 'x' )
ax.set_ylim(0, 98)
ax.set_ylabel( 'Frequency' )
ax.hist([x2, x1], bins, color=['#FFCC00', '#FFFF66' ])

ax = fig.add_subplot( 1, 2, 2 )
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
ax.yaxis.set_ticks_position('left')
ax.xaxis.set_ticks_position('bottom')
ax.set_xlim(0, 7)
ax.set_xticks( range(1, 7) )
ax.set_xlabel( 'x' )
ax.set_ylim(0, 0.23)
ax.set_ylabel( 'Probability' )
ax.plot([0.2, 6.8], [1.0/6.0, 1.0/6.0], '-b', lw=2, zorder=1)
ax.hist([x2, x1], bins, normed=True, color=['#FFCC00', '#FFFF66' ], zorder=10)
plt.tight_layout()
fig.savefig( 'diehistograms.pdf' )
#plt.show()
