This code allows to produce, in a very flexible way, publication quality HEP distributions based on ROOT histograms.
git clone https://github.com/rmadar/hepplotting
cd hepplotting
pip install -e . --user
- Histograms for every processes and data, and total histogram (for the uncertainty)
- Legend names and color definitions for every background
- Possibly every systematic variations to be passed through the total histogram (after appropriate combination across systematics, which is not performed by this tool)
The simplest use you can do is to call the following function, once you get your histograms (with their color):
import hepplotting as plt
plt.make_nice_canvas(dictBkg,hTot,hData,plot_name='myplot')
where:
dictBkg
is a dictionnary made of background name and the corresponding histogram{bname:[TH1F,color,leg_name]}
hTot
is the total histogram with possibly larger uncertainty (to account for systematics)hData
is the data histograms
A concrete example can be found in this notebook or this simple script which produce each this plot:
The point of this tool is to be able to highly tune many details on a plot-by-plot level, which is often required during the approval process of a publication.
Histogram properties
dictSig
[dict{sigName:[TH1,color,norm,legName]}
] is dictionnary withname
[string],histo
[TH1],color
[int],norm
[float] andlegName
[string] of several signalsm_size
[float] is the marker size for dataerror_fill
[int] is the filling style for the uncertainty banderror_alpha
[float] is the transparency for the uncertainty band (in[0,1]
)histo_border
[int] is the border size of background histograms in the stacks
Axis properties
xtitle
[string] is x-axis titleytitle
[string] is y-axis titlexmin
[float] lower x-axis valuexmax
[float] higher x-axis valueymin
[float] lower y-axis valueymax
[float] higher y-axis valuer_ymin
[float] lower y-axis value on the ratio plotr_ymax
[float] higher y-axis value on the ratio plotxticksInt
[bool] keep only integer values for x-axis ticksbin_label
[list of string] to name bins (e.g plots with one region yield per bin)xlabel_size
[float] size of the x-axis bin labelsxlabel_offset
[float] offset of the x-axis bin labels
Legend properties
leg_pos
[list of float] specify the legend position via bottom left (x1,y1) and top right (x2,y2) using[x1,y1,x2,y2]
unc_leg
[string] to tune the name of uncertainty (eg.stat-only
orStat #oplus Norm Syst.
)leg_ncols
[int] number of columns used for the legendleg_put_nevts
[bool] to print events yields in the legendleg_textsize
[float] size of the legend text (~0.030 to ~0.045)
Canvas properties
canvas
[TCanvas] on which to perform the plotsplot_ratio
[boolean] to plot or not the ratio panelis_logy
[boolean] to plot in log scale or notcan_ratio
[float] specify the canvas size such aswidth=900/ratio
andheight=800
can_scale
[float] specify the canvas size without ratio change such aswidth=900*scale
andheight=800*scale
plot_labels
[list of string] given the labels printed below ATLAS and Lumiatlas_label
[string] is 'Internal' by default but can be 'ATLAS', 'Preliminary', 'Simulation'
Output properties
plotdir
[string] is a directory where the plots will be stored (default isplots
)
- Add the possibility of having several legends with the position/number
if entry for each: done via
leg.SetNcolumns(ncols)
method; - Add sanity checks for the number of bins of each histograms and the
size of the
bin_label
list
- ROOT