Stacked and Unstacked Function Components

Setup
Code
fig, ax = mh.model(
stacked_components=[f_background1, f_background2],
stacked_labels=["c0", "c1"],
unstacked_components=[f_signal],
unstacked_labels=["Signal"],
unstacked_colors=["black"],
xlabel="Observable",
ylabel="f(Observable)",
model_sum_kwargs={"show": True, "label": "Model", "color": "navy"},
function_range=(-9, 12),
)
mh.add_text("Model made of functions", ax=ax, loc="over left", fontsize="small")
Full code
from scipy.stats import norm
import mplhep as mh
# Define model function components
def f_signal(x):
return 600 * norm.pdf(x, loc=0.2, scale=3)
def f_background1(x):
return 1000 * norm.pdf(x, loc=-1.5, scale=4)
def f_background2(x):
return 3000 * norm.pdf(x, loc=-3.2, scale=1.2)
fig, ax = mh.model(
stacked_components=[f_background1, f_background2],
stacked_labels=["c0", "c1"],
unstacked_components=[f_signal],
unstacked_labels=["Signal"],
unstacked_colors=["black"],
xlabel="Observable",
ylabel="f(Observable)",
model_sum_kwargs={"show": True, "label": "Model", "color": "navy"},
function_range=(-9, 12),
)
mh.add_text("Model made of functions", ax=ax, loc="over left", fontsize="small")