madminer.plotting package
Submodules
madminer.plotting.distributions module
- madminer.plotting.distributions.plot_distributions(filename, observables=None, parameter_points=None, uncertainties='nuisance', nuisance_parameters=None, draw_nuisance_toys=None, normalize=False, log=False, observable_labels=None, n_bins=50, line_labels=None, colors=None, linestyles=None, linewidths=1.5, toy_linewidths=0.5, alpha=0.15, toy_alpha=0.75, n_events=None, n_toys=100, n_cols=3, quantiles_for_range=(0.025, 0.975), sample_only_from_closest_benchmark=True)[source]
Plots one-dimensional histograms of observables in a MadMiner file for a given set of benchmarks.
- Parameters
- filenamestr
Filename of a MadMiner HDF5 file.
- observableslist of str or None, optional
Which observables to plot, given by a list of their names. If None, all observables in the file are plotted. Default value: None.
- parameter_pointslist of (str or ndarray) or None, optional
Which parameter points to use for histogramming the data. Given by a list, each element can either be the name of a benchmark in the MadMiner file, or an ndarray specifying any parameter point in a morphing setup. If None, all physics (non-nuisance) benchmarks defined in the MadMiner file are plotted. Default value: None.
- uncertainties{“nuisance”, “none”}, optional
Defines how uncertainty bands are drawn. With “nuisance”, the variation in cross section from all nuisance parameters is added in quadrature. With “none”, no error bands are drawn.
- nuisance_parametersNone or list of int, optional
If uncertainties is “nuisance”, this can restrict which nuisance parameters are used to draw the uncertainty bands. Each entry of this list is the index of one nuisance parameter (same order as in the MadMiner file).
- draw_nuisance_toysNone or int, optional
If not None and uncertainties is “nuisance”, sets the number of nuisance toy distributions that are drawn (in addition to the error bands).
- normalizebool, optional
Whether the distribution is normalized to the total cross section. Default value: False.
- logbool, optional
Whether to draw the y axes on a logarithmic scale. Default value: False.
- observable_labelsNone or list of (str or None), optional
x-axis labels naming the observables. If None, the observable names from the MadMiner file are used. Default value: None.
- n_binsint, optional
Number of histogram bins. Default value: 50.
- line_labelsNone or list of (str or None), optional
Labels for the different parameter points. If None and if parameter_points is None, the benchmark names from the MadMiner file are used. Default value: None.
- colorsNone or str or list of str, optional
Matplotlib line (and error band) colors for the distributions. If None, uses default colors. Default value: None.
- linestylesNone or str or list of str, optional
Matplotlib line styles for the distributions. If None, uses default linestyles. Default value: None.
- linewidthsfloat or list of float, optional
Line widths for the contours. Default value: 1.5.
- toy_linewidthsfloat or list of float or None, optional
Line widths for the toy replicas, if uncertainties is “nuisance” and draw_nuisance_toys is not None. If None, linewidths is used. Default value: 1.
- alphafloat, optional
alpha value for the uncertainty bands. Default value: 0.25.
- toy_alphafloat, optional
alpha value for the toy replicas, if uncertainties is “nuisance” and draw_nuisance_toys is not None. Default value: 0.75.
- n_eventsNone or int, optional
If not None, sets the number of events from the MadMiner file that will be analyzed and plotted. Default value: None.
- n_toysint, optional
Number of toy nuisance parameter vectors used to estimate the systematic uncertainties. Default value: 100.
- n_colsint, optional
Number of columns of subfigures in the plot. Default value: 3.
- quantiles_for_rangetuple of two float, optional
Tuple (min_quantile, max_quantile) that defines how the observable range is determined for each panel. Default: (0.025, 0.075).
- sample_only_from_closest_benchmarkbool, optional
If True, only weighted events originally generated from the closest benchmarks are used. Default value: True.
- Returns
- figureFigure
Plot as Matplotlib Figure instance.
- madminer.plotting.distributions.plot_histograms(histos, observed=None, observed_weights=None, xrange=None, yrange=None, zrange=None, log=False, histo_labels=None, observed_label='Data', xlabel=None, ylabel=None, zlabel=None, colors=None, linestyles=None, linewidths=1.5, markercolor='black', markersize=20.0, cmap='viridis', n_cols=2)[source]
madminer.plotting.fisherinformation module
- madminer.plotting.fisherinformation.plot_distribution_of_information(xbins, xsecs, fisher_information_matrices, fisher_information_matrices_aux=None, xlabel=None, xmin=None, xmax=None, log_xsec=False, norm_xsec=True, epsilon=1e-09, figsize=(5.4, 4.5), fontsize=None)[source]
Plots the distribution of the cross section together with the distribution of the Fisher information.
- Parameters
- xbinslist of float
Bin boundaries.
- xsecslist of float
Cross sections (in pb) per bin.
- fisher_information_matriceslist of ndarray
Fisher information matrices for each bin.
- fisher_information_matrices_auxlist of ndarray or None, optional
Additional Fisher information matrices for each bin (will be plotted with a dashed line).
- xlabelstr or None, optional
Label for the x axis.
- xminfloat or None, optional
Minimum value for the x axis.
- xmaxfloat or None, optional
Maximum value for the x axis.
- log_xsecbool, optional
Whether to plot the cross section on a logarithmic y axis.
- norm_xsecbool, optional
Whether the cross sections are normalized to 1.
- epsilonfloat, optional
Numerical factor.
- figsizetuple of float, optional
Figure size, default: (5.4, 4.5)
- fontsize: float, optional
Fontsize, default None
- Returns
- figureFigure
Plot as Matplotlib Figure instance.
- madminer.plotting.fisherinformation.plot_fisher_information_contours_2d(fisher_information_matrices, fisher_information_covariances=None, reference_thetas=None, contour_distance=1.0, xlabel='$\\theta_0$', ylabel='$\\theta_1$', xrange=(-1.0, 1.0), yrange=(-1.0, 1.0), labels=None, inline_labels=None, resolution=500, colors=None, linestyles=None, linewidths=1.5, alphas=1.0, alphas_uncertainties=0.25, sigma_uncertainties=1, ax=None)[source]
Visualizes 2x2 Fisher information matrices as contours of constant Fisher distance from a reference point theta0.
The local (tangent-space) approximation is used: distances d(theta) are given by d(theta)^2 = (theta - theta0)_i I_ij (theta - theta0)_j, summing over i and j.
- Parameters
- fisher_information_matriceslist of ndarray
Fisher information matrices, each with shape (2,2).
- fisher_information_covariancesNone or list of (ndarray or None), optional
Covariance matrices for the Fisher information matrices. Has to have the same length as fisher_information_matrices, and each entry has to be None (no uncertainty) or a tensor with shape (2,2,2,2). Default value: None.
- reference_thetasNone or list of (ndarray or None), optional
Reference points from which the distances are calculated. If None, the origin (0,0) is used. Default value: None.
- contour_distancefloat, optional.
Distance threshold at which the contours are drawn. Default value: 1.
- xlabelstr, optional
Label for the x axis. Default value: r’$ heta_0$’.
- ylabelstr, optional
Label for the y axis. Default value: r’$ heta_1$’.
- xrangetuple of float, optional
Range (min, max) for the x axis. Default value: (-1., 1.).
- yrangetuple of float, optional
Range (min, max) for the y axis. Default value: (-1., 1.).
- labelsNone or list of (str or None), optional
Legend labels for the contours. Default value: None.
- inline_labelsNone or list of (str or None), optional
Inline labels for the contours. Default value: None.
- resolutionint
Number of points per axis for the calculation of the distances. Default value: 500.
- colorsNone or str or list of str, optional
Matplotlib line (and error band) colors for the contours. If None, uses default colors. Default value: None.
- linestylesNone or str or list of str, optional
Matploitlib line styles for the contours. If None, uses default linestyles. Default value: None.
- linewidthsfloat or list of float, optional
Line widths for the contours. Default value: 1.5.
- alphasfloat or list of float, optional
Opacities for the contours. Default value: 1.
- alphas_uncertaintiesfloat or list of float, optional
Opacities for the error bands. Default value: 0.25.
- sigma_uncertaintiesfloat, optional
Number of gaussian sigmas used when presenting uncertainty bands. Default value: 1.
- ax: axes or None, optional
Predefined axes as part of figure instead of standalone figure. Default: None
- Returns
- figureFigure
Plot as Matplotlib Figure instance.
- madminer.plotting.fisherinformation.plot_fisherinfo_barplot(fisher_information_matrices, labels, determinant_indices=None, eigenvalue_colors=None, bar_colors=None)[source]
- Parameters
- fisher_information_matriceslist of ndarray
Fisher information matrices
- labelslist of str
Labels for the x axis
- determinant_indiceslist of int or None, optional
If not None, the determinants will be based only on the indices given here. Default value: None.
- eigenvalue_colorsNone or list of str
Colors for the eigenvalue decomposition. If None, default colors are used. Default value: None.
- bar_colorsNone or list of str
Colors for the determinant bars. If None, default colors are used. Default value: None.
- Returns
- figureFigure
Plot as Matplotlib Figure instance.
madminer.plotting.limits module
- madminer.plotting.limits.plot_pvalue_limits(p_values, best_fits, labels, grid_ranges, grid_resolutions, levels=[0.32], single_plot=True, show_index=None, xlabel='$\\theta_0$', ylabel='$\\theta_1$', p_val_min=0.001, p_val_max=1)[source]
Function that plots the limits obtained from the AsymptoticLimits, Likelihood, FisherInformation and Information Geometry class. Note that only 2 dimensional grids are supported.
- Parameters
- p_valueslist of ndarray or dict
List/dictionary of p-values with shape (nmethods, ngridpoints)
- best_fitslist of int or dict
List/dictionary of best fit points for each method with shape (nmethods)
- labelslist of string or None
List/dictionary of best labels for each method with shape (nmethods). If None, it is assumed that dictionaries are provided and all entries will be used.
- grid_rangeslist of (tuple of float) or None, optional
Specifies the boundaries of the parameter grid on which the p-values are evaluated. It should be [(min, max), (min, max), …, (min, max)], where the list goes over all parameters and min and max are float. If None, thetas_eval has to be given. Default: None.
- grid_resolutionsint or list of int, optional
Resolution of the parameter space grid on which the p-values are evaluated. If int, the resolution is the same along every dimension of the hypercube. If list of int, the individual entries specify the number of points along each parameter individually. Doesn’t have any effect if grid_ranges is None. Default value: 25.
- levelslist of float, optional
list of p-values used to draw contour lines. Default: [0.32]
- single_plotbool, optional
If True, only one summary plot is shown which contains confidence contours and best fit points for all methods, and the p-value grid for a selected method (if show_index is not None). If False, additional plots with the p-value grid, confidence contours and best fit points for all methods are provided. Default: True
- show_indexint, optional
If None, no p-value grid is shown in summary plot. If show_index=n, the p-value grid of the nth method is shown in the summary plot. Default is None.
- xlabel,ylabelstring, optional
Labels for the x and y axis. Default: xlabel=r’$ heta_0$’ and ylabel=r’$ heta_1$’.
- p_val_min,p_val_maxfloat, optional
Plot range for p-values. Default: p_val_min=0.001 and p_val_max=1.
madminer.plotting.morphing module
- madminer.plotting.morphing.plot_1d_morphing_basis(morpher, xlabel='$\\theta$', xrange=(-1.0, 1.0), resolution=100)[source]
Visualizes a morphing basis and morphing errors for problems with a two-dimensional parameter space.
- Parameters
- morpherPhysicsMorpher
PhysicsMorpher instance with defined basis.
- xlabelstr, optional
Label for the x axis. Default value: r’$ heta$’.
- xrangetuple of float, optional
Range (min, max) for the x axis. Default value: (-1., 1.).
- resolutionint, optional
Number of points per axis for the rendering of the squared morphing weights. Default value: 100.
- Returns
- figureFigure
Plot as Matplotlib Figure instance.
- madminer.plotting.morphing.plot_2d_morphing_basis(morpher, xlabel='$\\theta_0$', ylabel='$\\theta_1$', xrange=(-1.0, 1.0), yrange=(-1.0, 1.0), crange=(1.0, 100.0), resolution=100)[source]
Visualizes a morphing basis and morphing errors for problems with a two-dimensional parameter space.
- Parameters
- morpherPhysicsMorpher
PhysicsMorpher instance with defined basis.
- xlabelstr, optional
Label for the x axis. Default value: r’$ heta_0$’.
- ylabelstr, optional
Label for the y axis. Default value: r’$ heta_1$’.
- xrangetuple of float, optional
Range (min, max) for the x axis. Default value: (-1., 1.).
- yrangetuple of float, optional
Range (min, max) for the y axis. Default value: (-1., 1.).
- crangetuple of float, optional
Range (min, max) for the color map. Default value: (1., 100.).
- resolutionint, optional
Number of points per axis for the rendering of the squared morphing weights. Default value: 100.
- Returns
- figureFigure
Plot as Matplotlib Figure instance.
- madminer.plotting.morphing.plot_nd_morphing_basis_scatter(morpher, crange=(1.0, 100.0), n_test_thetas=1000)[source]
Visualizes a morphing basis and morphing errors with scatter plots between each pair of operators.
- Parameters
- morpherPhysicsMorpher
PhysicsMorpher instance with defined basis.
- crangetuple of float, optional
Range (min, max) for the color map. Default value: (1. 100.).
- n_test_thetasint, optional
Number of random points evaluated. Default value: 1000.
- Returns
- figureFigure
Plot as Matplotlib Figure instance.
- madminer.plotting.morphing.plot_nd_morphing_basis_slices(morpher, crange=(1.0, 100.0), resolution=50)[source]
Visualizes a morphing basis and morphing errors with two-dimensional slices through parameter space.
- Parameters
- morpherPhysicsMorpher
PhysicsMorpher instance with defined basis.
- crangetuple of float, optional
Range (min, max) for the color map.
- resolutionint, optional
Number of points per panel and axis for the rendering of the squared morphing weights. Default value: 50.
- Returns
- figureFigure
Plot as Matplotlib Figure instance.
madminer.plotting.uncertainties module
- madminer.plotting.uncertainties.plot_systematics(filename, theta, observable, obs_label, obs_range, n_bins=50, n_events=None, n_toys=100, linecolor='black', bandcolors=None, band_alpha=0.2, ratio_range=(0.8, 1.2))[source]
Plots absolute and relative uncertainty bands for all systematic uncertainties in a histogram of one observable in a MadMiner file.
- Parameters
- filenamestr
Filename of a MadMiner HDF5 file.
- thetandarray, optional
Which parameter points to use for histogramming the data.
- observablestr
Which observable to plot, given by its name in the MadMiner file.
- obs_labelstr
x-axis label naming the observable.
- obs_rangetuple of two float
Range to be plotted for the observable.
- n_binsint
Number of bins. Default value: 50.
- n_eventsNone or int, optional
If not None, sets the number of events from the MadMiner file that will be analyzed and plotted. Default value: None.
- n_toysint, optional
Number of toy nuisance parameter vectors used to estimate the systematic uncertainties. Default value: 100.
- linecolorstr, optional
Line color for central prediction. Default value: “black”.
- bandcolorsNone or list of str, optional
Error band colors. Default value: None.
- ratio_rangetuple of two float
y-axis range for the plots of the ratio to the central prediction. Default value: (0.8, 1.2).
- Returns
- figureFigure
Plot as Matplotlib Figure instance.
- madminer.plotting.uncertainties.plot_uncertainty(filename, theta, observable, obs_label, obs_range, n_bins=50, systematics=None, n_events=None, n_toys=100, linecolor='black', bandcolor1='#CC002E', bandcolor2='orange', ratio_range=(0.8, 1.2))[source]
Plots absolute and relative uncertainty bands in a histogram of one observable in a MadMiner file.
- Parameters
- filenamestr
Filename of a MadMiner HDF5 file.
- thetandarray, optional
Which parameter points to use for histogramming the data.
- observablestr
Which observable to plot, given by its name in the MadMiner file.
- obs_labelstr
x-axis label naming the observable.
- obs_rangetuple of two float
Range to be plotted for the observable.
- n_binsint
Number of bins. Default value: 50.
- systematicsNone or list of str, optional
This can restrict which nuisance parameters are used to draw the uncertainty bands. Each entry of this list is the name of a systematic uncertainty (see MadMiner.add_systematics()).
- n_eventsNone or int, optional
If not None, sets the number of events from the MadMiner file that will be analyzed and plotted. Default value: None.
- n_toysint, optional
Number of toy nuisance parameter vectors used to estimate the systematic uncertainties. Default value: 100.
- linecolorstr, optional
Line color for central prediction. Default value: “black”.
- bandcolor1str, optional
Error band color for 1 sigma uncertainty. Default value: “#CC002E”.
- bandcolor2str, optional
Error band color for 2 sigma uncertainty. Default value: “orange”.
- ratio_rangetuple of two floar
y-axis range for the plots of the ratio to the central prediction. Default value: (0.8, 1.2).
- Returns
- figureFigure
Plot as Matplotlib Figure instance.