tdub.art

A module for art (plots)

Function Summary

canvas_from_counts(counts, errors, bin_edges)

Create a plot canvas given a dictionary of counts and bin edges.

draw_atlas_label(ax[, follow, cme_and_lumi, ...])

Draw the ATLAS label text, with extra lines if desired.

draw_impact_barh(ax, df[, hi_color, ...])

Draw the impact plot.

draw_uncertainty_bands(uncertainty, ...[, ...])

Draw uncertainty bands on both axes in stack plot with a ratio.

legend_last_to_first(ax, **kwargs)

Move the last element of the legend to first.

one_sided_comparison_plot(nominal, one_up, edges)

Create plot for one sided systematic comparison.

setup_tdub_style()

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 and errors 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:

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.

  • cme (int or float) – Center-of-mass energy.

  • lumi (int or float) – Integrated luminosity of the data.

  • 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:
tdub.art.one_sided_comparison_plot(nominal, one_up, edges, thesis=False)[source]

Create plot for one sided systematic comparison.

Parameters:
Returns:

tdub.art.setup_tdub_style()[source]

Modify matplotlib’s rcParams to our preference.