cogwheel.gw_plotting.CornerPlot

class cogwheel.gw_plotting.CornerPlot(samples: DataFrame, params=None, plotstyle=None, weights_col='weights', latex_labels=None, **plotstyle_kwargs)

Bases: CornerPlot

Has default latex labels for gravitational wave parameters.

Parameters:
samplespandas.DataFrame

Columns correspond to parameters to plot and rows correspond to samples.

paramslist of str, optional

Subset of columns present in all dataframes, to plot a reduced number of parameters.

plotstylePlotStyle

Determines the colors, linestyles, etc.

weights_colstr, optional

If existing, use a column with this name to set weights for the samples. Pass None to ignore, if you have a column named ‘weights’ that is not to be interpreted as weights.

latex_labelsLatexLabels

Maps column names to latex strings and assigns units.

**plotstyle_kwargs

Passed to PlotStyle constructor, ignored if plotstyle is passed.

Other Parameters:
confidence_levelfloat between 0 and 1, or None

Determines the reported confidence interval around the median (highlighted band in 1-d marginal probability and numeric values in the subplot titles). If None, both the numerical values and highlighted bands are removed.

contour_fractionssequence of floats

Fractions of the distribution to enclose by 2-d contours.

binsint | {‘rice’, ‘sturges’, ‘sqrt’}

How many histogram bins to use, the same for all parameters.

color_2dstr, RGB tuple, etc.

Color used for the 2-d marginal distributions.

contour_kwargsdict

Keyword arguments to plt.contour and plt.contourf

vline_kwargsdict

Keyword arguments to plt.plot for the vertical lines signaling medians and 1-d confidence intervals.

vfill_kwargsdict

Keyword arguments to plt.fill_between for 1-d plots.

kwargs_1ddict

Keyword arguments to plt.plot for 1-d plots.

clabel_kwargsdict, optional

Keyword arguments for contour labels. Pass an empty dict to use defaults. None draws no contour labels.

fill{‘gradient’, ‘flat’, ‘none’}

How to display 2-d marginal distributions:

  • ‘gradient’ shows the 2d pdf with a transparency gradient

  • ‘flat’ fills the contours with a flat transparent color

  • ‘none’ shows just the contours

smoothfloat

Smooth the 2d histograms by convolving them with a Gaussian kernel with this standard deviation in pixel units. 0 (default) does no smoothing.

densitybool

Whether to normalize the 1-d histograms to integrate to 1.

tail_probabilityfloat between 0 and 1

Disregard tail_probability / 2 of the distribution to either side in the plots. Used as an automatic way of zooming in on the interesting part of the distribution if there are a few outlier samples. 0 (default) includes all samples.

Methods

get_current_lims

Return dictionary of the form {par: (vmin, vmax)} with current plot limits for all parameters in self.params.

plot

Make a corner plot of the distribution.

plot_2d

Plot just one panel of the corner plot.

scatter_points

Add scatter points to an existing corner plot.

set_lims

Set x and y limits of the plots.

Attributes

DEFAULT_LATEX_LABELS

MARGIN_INCHES

get_current_lims()

Return dictionary of the form {par: (vmin, vmax)} with current plot limits for all parameters in self.params.

plot(fig=None, title=None, max_figsize=10.0, max_n_ticks=4, label=None, legend_title=None)

Make a corner plot of the distribution.

Parameters:
figmatplotlib.Figure, optional

If provided, will reuse this figure to make the plot. Must have axes matching the number of parameters.

titlestr, optional

Figure title.

max_figsizefloat

Maximum size in inches of a side of the square figure. Ignored if fig is passed.

max_n_ticksint

Determines the number of ticks in each subplot. Ignored if fig is passed.

labelstr, optional

Legend label.

legend_titlestr, optional

Legend title.

plot_2d(xpar, ypar, ax=None)

Plot just one panel of the corner plot.

Parameters:
xpar, yparstr

Parameters in self.params to plot in the x and y axes.

axmatplotlib.axes.Axes or None

Axes on which to draw the figure. None makes new axes.

labelstr

Add a legend element with this label.

scatter_points(scatter_points, colors=None, adjust_lims=False, **kwargs)

Add scatter points to an existing corner plot. For every point passed, one vertical line in the diagonal panels and one dot in each off-diagonal panel will be plotted.

Parameters:
scatter_pointspandas.DataFrame or dict

Columns are parameter names, must contain self.params. Rows correspond to parameter values. A dict is acceptable to plot a single point.

colorsiterable, optional

Colors corresponding to each scatter point passed.

adjust_limsbool

Whether to adjust x and y limits in the case that the scatter points lie outside or very near the current limits.

**kwargs

Passed to matplotlib.axes.Axes.scatter.

set_lims(**lims)

Set x and y limits of the plots.

Parameters:
**lims

Keyword arguments of the form par=(vmin, vmax) for those parameters whose limits that are to be adjusted.