A custom style: colours, legend position, figure size, rcParams¶
Style bundles appearance: a colour cycle, the legend location, the figure size and
any matplotlib rcParams. It applies only while the figure is drawn; global matplotlib
state is untouched unless you call rf.use_style.

import rootfig as rf
style = rf.Style(
colors=["#7570b3", "#e7298a"],
legend="upper left",
figsize=(6.5, 5),
rc={"font.size": 14, "axes.grid": True, "grid.alpha": 0.3},
)
rf.plot(
[signal, zjets],
rf.Variable("Jet_btag", bins=(25, 0, 1), label="Jet b-tag score"),
selection="Jet_pt > 30",
normalize=True,
histtype="fill",
style=style,
)
Setup
The code reads the toy dataset. In a checkout of rootfig, python examples/gallery writes it to examples/out/ in a few seconds; run the code inside that directory.
It uses these samples and variables, shared by the gallery examples (see Samples, variables, cuts and styles):
signal = rf.Sample("signal.root", tree="events", label="Signal", weight="weight", scale=0.03)
zjets = rf.Sample("background.root", tree="events", label="Z + jets", weight="weight")
diboson = rf.Sample("diboson.root", tree="events", label="Diboson", weight="weight", scale=0.15)
data = rf.Sample("data.root", tree="events", label="Data", is_data=True)
mc = [zjets, diboson, signal] # stacked bottom to top
pt = rf.Variable("Muon_pt", bins=(30, 0, 300), label=r"$p_T^{\mu}$", unit="GeV")
mll = rf.Variable("m_ll", bins=(70, 50, 260), label=r"$m_{\ell\ell}$", unit="GeV")
met = rf.Variable("MET", bins=(40, 0, 400), label=r"$E_T^{miss}$", unit="GeV")