import numpy as np import matplotlib.pyplot as plt from plotstyle import * # roll the die: rng = np.random.RandomState(57281) x1 = rng.randint(1, 7, 100) x2 = rng.randint(1, 7, 500) bins = np.arange(0.5, 7, 1.0) fig, (ax1, ax2) = plt.subplots(1, 2) fig.subplots_adjust(**adjust_fs(bottom=2.7, top=0.1)) ax1.set_xlim(0, 7) ax1.set_xticks(range(1, 7)) ax1.set_xlabel('x') ax1.set_ylim(0, 98) ax1.set_ylabel('Frequency') fs = dict(**fsC) fs['color'] = [fsC['facecolor'], fsE['facecolor']] del fs['facecolor'] ax1.hist([x2, x1], bins, **fs) ax2.set_xlim(0, 7) ax2.set_xticks(range(1, 7)) ax2.set_xlabel('x') ax2.set_ylim(0, 0.23) ax2.set_ylabel('Probability') ax2.plot([0.2, 6.8], [1.0/6.0, 1.0/6.0], zorder=-10, **lsAm) h1, b1 = np.histogram(x1, bins) h2, b2 = np.histogram(x2, bins) h1 = h1/np.sum(h1) h2 = h2/np.sum(h2) ax2.bar(b1[:-1]+0.3, h1, zorder=-5, width=0.4, **fsC) ax2.bar(b2[:-1]+0.7, h2, zorder=-5, width=0.4, **fsE) fig.subplots_adjust(left=0.125) fig.savefig('diehistograms.pdf')