XKCD theme#

Simple gaussian fit to histogram data with the XKCD theme.

xkcd theme
Gaussian
χ²: 80.75 / 81 dof
amplitude: 10093±32
mu: 0.0019±0.0032
sigma: 0.9993±0.0022 (min=0.0)

<matplotlib.legend.Legend object at 0x7f9d3c12b560>

import numpy as np

from aptapy.hist import Histogram1d
from aptapy.models import Gaussian
from aptapy.plotting import apply_stylesheet, plt

# You can either use the stylesheet_context() context manager, or apply the stylesheet
# directly, as we do here.
apply_stylesheet("aptapy-xkcd")

hist = Histogram1d(np.linspace(-5., 5., 100), label="Random data", xlabel="z")
hist.fill(np.random.default_rng().normal(size=100000))
hist.plot(statistics=True)

model = Gaussian()
model.fit(hist)
print(model)
# Plot the model, including the fit output in the legend.
model.plot(fit_output=True)

plt.legend()

Total running time of the script: (0 minutes 0.382 seconds)

Gallery generated by Sphinx-Gallery