Source code for validphys.closuretest.closure_plots

"""
closuretest/plots.py

Plots of statistical estimators for single closure test.
See multiclosure module for more estimators and plots.
"""

from reportengine.figure import figure
from validphys import plotutils


[docs]@figure def plot_delta_chi2(delta_chi2_bootstrap, fits): """Plots distributions of delta chi2 for each fit in `fits`. Distribution is generated by bootstrapping. For more information on delta chi2 see `delta_chi2_bootstrap` """ delta_chi2 = delta_chi2_bootstrap.T labels = [fit.label for fit in fits] fig, ax = plotutils.subplots() for i, label in enumerate(labels): ax.hist(delta_chi2[:, i], alpha=0.3, label=label, zorder=100) ax.set_xlabel(r"$\Delta_{\chi^{2}}$") l = ax.legend() l.set_zorder(1000) ax.set_title(r"Total $\Delta_{\chi^{2}}$ for each fit") return fig
[docs]def errorbar_figure_from_table(df): """Given a table with even columns as central values as odd columns as errors plot an errorbar plot""" fig, ax = plotutils.plot_horizontal_errorbars( df.values[:, ::2].T, df.values[:, 1::2].T, df.index.values, df.columns.unique(0), xlim=0 ) return fig, ax