import locale import matplotlib import numpy as np import matplotlib.pyplot as plt import sys locale.setlocale(locale.LC_NUMERIC, 'en_US.UTF-8') matplotlib.use('pgf') matplotlib.rcParams.update({ 'pgf.texsystem': 'pdflatex', 'pgf.preamble': '\n'.join([ r'\usepackage[T1]{fontenc}', ]), 'pgf.rcfonts': False, 'font.family': 'serif', 'font.size' : 11, 'axes.formatter.use_locale': True, }) np.random.seed(19680801) mu = 100 sigma = 15 x = mu + sigma * np.random.randn(437) num_bins = 50 fig, ax = plt.subplots() n, bins, patches = ax.hist(x, num_bins, density=1) y = ((1 / (np.sqrt(2 * np.pi) * sigma)) * np.exp(-0.5 * (1 / sigma * (bins - mu))**2)) ax.plot(bins, y, '--') ax.set_xlabel('Smarts') ax.set_ylabel('Probability density') ax.set_title(rf'Histogram of IQ: $\mu={mu}$, $\sigma={sigma}$') fig.tight_layout(pad=1.5) fig.set_size_inches(4.7747, 3.5) plt.savefig(sys.stdout.buffer, format='pgf')