tdub.art¶
A module for art (plots)
Function Summary¶
|
Create a plot canvas given a dictionary of counts and bin edges. |
|
Draw the ATLAS label text, with extra lines if desired. |
|
Draw the impact plot. |
|
Draw uncertainty bands on both axes in stack plot with a ratio. |
|
Move the last element of the legend to first. |
|
Create plot for one sided systematic comparison. |
Modify matplotlib's rcParams to our preference. |
Reference¶
- tdub.art.canvas_from_counts(counts, errors, bin_edges, uncertainty=None, total_mc=None, logy=False, mpl_triplet=None, combine_minor=True, **subplots_kw)[source]¶
Create a plot canvas given a dictionary of counts and bin edges.
The
counts
anderrors
dictionaries are expected to have the following keys:“Data”
“tW_DR” or “tW”
“ttbar”
“Zjets”
“Diboson”
“MCNP”
- Parameters:
counts (dict(str, np.ndarray)) – a dictionary pairing samples to bin counts.
errors (dict(str, np.ndarray)) – a dictionray pairing samples to bin count errors.
bin_edges (array_like) – the histogram bin edges.
uncertainty (tdub.root.TGraphAsymmErrors) – Uncertainty (TGraphAsym).
total_mc (tdub.root.TH1) – Total MC histogram (TH1D).
logy (bool) – Use log scale on y-axis.
mpl_triplet ((plt.Figure, plt.Axes, plt.Axes), optional) – Existing matplotlib triplet.
combine_minor (bool) – Combine minor backgrounds into a single contribution (Zjets, Diboson, and MCNP will be labeled “Minor Backgrounds”).
subplots_kw (dict) – remaining keyword arguments passed to
matplotlib.pyplot.subplots()
.
- Returns:
matplotlib.figure.Figure
– Matplotlib figure.matplotlib.axes.Axes
– Matplotlib axes for the histogram stack.matplotlib.axes.Axes
– Matplotlib axes for the ratio comparison.
- tdub.art.draw_atlas_label(ax, follow='Internal', cme_and_lumi=True, extra_lines=None, cme=13, lumi=139, x=0.04, y=0.905, follow_shift=0.17, s1=18, s2=14, thesis=False)[source]¶
Draw the ATLAS label text, with extra lines if desired.
- Parameters:
ax (matplotlib.axes.Axes) – Axes to draw the text on.
follow (str) – Text to follow the ATLAS label (usually ‘Internal’).
extra_lines (list(str), optional) – Set of extra lines to draw below ATLAS label.
x (float) – x-location of the text.
y (float) – y-location of the text.
follow_shift (float) – x-shift of the text following the ATLAS label.
s1 (int) – Size of the main label.
s2 (int) – Size of the extra text
thesis (bool) – Flag for is thesis
- tdub.art.draw_impact_barh(ax, df, hi_color='steelblue', lo_color='mediumturquoise', height_fill=0.8, height_line=0.8)[source]¶
Draw the impact plot.
- Parameters:
ax (matplotlib.axes.Axes) – Axes for the “delta mu” impact.
df (pandas.DataFrame) – Dataframe containing impact information.
hi_color (str) – Up variation color.
lo_color (str) – Down variation color.
height_fill (float) – Height for the filled bars (post-fit).
height_line (float) – Height for the line (unfilled) bars (pre-fit).
- Returns:
matplotlib.axes.Axes – Axes for the impact: “delta mu”.
matplotlib.axes.Axes – Axes for the nuisance parameter pull.
- tdub.art.draw_uncertainty_bands(uncertainty, total_mc, ax, axr, label='Uncertainty', edgecolor='mediumblue', zero_threshold=0.25)[source]¶
Draw uncertainty bands on both axes in stack plot with a ratio.
- Parameters:
uncertainty (tdub.root.TGraphAsymmErrors) – ROOT TGraphAsymmErrors with full systematic uncertainty.
total_mc (tdub.root.TH1) – ROOT TH1 providing the full Monte Carlo prediction.
ax (matplotlib.axes.Axes) – Main axis (where histogram stack is painted)
axr (matplotlib.axes.Axes) – Ratio axis
label (str) – Legend label for the uncertainty.
zero_threshold (float) – When total MC events are below threshold, zero contents and error.
- tdub.art.legend_last_to_first(ax, **kwargs)[source]¶
Move the last element of the legend to first.
- Parameters:
ax (matplotlib.axes.Axes) – Matplotlib axes to create a legend on.
kwargs (dict) – Arguments passed to
matplotlib.axes.Axes.legend
.
- tdub.art.one_sided_comparison_plot(nominal, one_up, edges, thesis=False)[source]¶
Create plot for one sided systematic comparison.
- Parameters:
nominal (numpy.ndarray) – Nominal histogram bin counts.
one_up (numpy.ndarray) – One \(\sigma\) up variation.
edges (numpy.ndarray) – Array defining bin edges.
thesis (bool) – Label for thesis figure.
- Returns:
matplotlib.figure.Figure
– Matplotlib figure.matplotlib.axes.Axes
– Matplotlib axes for the histograms.matplotlib.axes.Axes
– Matplotlib axes for the percent difference comparison.