pyhf.contrib.viz.brazil.plot_brazil_band

pyhf.contrib.viz.brazil.plot_brazil_band(test_pois, cls_obs, cls_exp, test_size, ax, **kwargs)[source]

Plot the values of \(\mathrm{CL}_{s,\mathrm{obs}}\) and the \(\mathrm{CL}_{s,\mathrm{exp}}\) band (the “Brazil band”) for a series of hypothesis tests for various POI values.

Example

plot_brazil_band() is generally meant to be used inside plot_results() but can be used by itself.

>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> import pyhf
>>> import pyhf.contrib.viz.brazil
>>> pyhf.set_backend("numpy")
>>> model  = pyhf.simplemodels.uncorrelated_background(
...     signal=[12.0, 11.0], bkg=[50.0, 52.0], bkg_uncertainty=[3.0, 7.0]
... )
>>> observations = [51, 48]
>>> data = observations + model.config.auxdata
>>> test_pois = np.linspace(0, 5, 41)
>>> results = [
...     pyhf.infer.hypotest(test_poi, data, model, return_expected_set=True)
...     for test_poi in test_pois
... ]
>>> cls_obs = np.array([test[0] for test in results]).flatten()
>>> cls_exp = [
...     np.array([test[1][sigma_idx] for test in results]).flatten()
...     for sigma_idx in range(5)
... ]
>>> test_size = 0.05
>>> fig, ax = plt.subplots()
>>> artists = pyhf.contrib.viz.brazil.plot_brazil_band(
...     test_pois, cls_obs, cls_exp, test_size, ax
... )
Parameters:
  • test_pois (list or array) – The values of the POI where the hypothesis tests were performed.

  • cls_obs (list or array) – The values of \(\mathrm{CL}_{s,\mathrm{obs}}\) for the POIs tested in test_pois.

  • cls_exp (list or array) – The values of the \(\mathrm{CL}_{s,\mathrm{exp}}\) band for the POIs tested in test_pois.

  • test_size (float) – The size, \(\alpha\), of the test.

  • ax (matplotlib.axes.Axes) – The matplotlib axis object to plot on.

Returns:

The matplotlib.artist objects drawn.

Return type:

tuple