pyhf.contrib.viz.brazil.plot_results#

pyhf.contrib.viz.brazil.plot_results(test_pois, tests, test_size=0.05, ax=None, **kwargs)[source]#

Plot a series of hypothesis tests for various POI values. For more detail on use of keywords see plot_brazil_band() and plot_cls_components().

Example

A Brazil band plot.

>>> 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
... ]
>>> fig, ax = plt.subplots()
>>> artists = pyhf.contrib.viz.brazil.plot_results(test_pois, results, ax=ax)

A Brazil band plot with the components of the \(\mathrm{CL}_{s}\) ratio drawn on top.

>>> 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, return_tail_probs=True
...     )
...     for test_poi in test_pois
... ]
>>> fig, ax = plt.subplots()
>>> artists = pyhf.contrib.viz.brazil.plot_results(
...     test_pois, results, ax=ax, components=True
... )
Parameters:
  • test_pois (list or array) – The values of the POI where the hypothesis tests were performed.

  • tests (list or array) – The collection of \(p\)-value-like values (\(\mathrm{CL}_{s}\) values or tail probabilities) from the hypothesis tests. If the components keyword argument is True, tests is required to have the same structure as pyhf.infer.hypotest()’s return when using return_expected_set=True and return_tail_probs=True: a tuple of \(\mathrm{CL}_{s}\), \(\left[\mathrm{CL}_{s+b}, \mathrm{CL}_{b}\right]\), \(\mathrm{CL}_{s,\mathrm{exp}}\) band.

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

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

Returns:

Artist containing the matplotlib.artist objects drawn.

Return type:

BrazilBandCollection