curepy.utilities.plotting module

curepy.utilities.plotting module#

curepy.utilities.plotting.hist2d(x, y, fig, bins: int = 20, range=None, weights=None, levels=None, smooth=None, ax=None, color: str = None, plot_datapoints: bool = True, plot_density: bool = True, plot_contours: bool = True, no_fill_contours: bool = False, fill_contours: bool = False, contour_kwargs: dict = None, contourf_kwargs: dict = None, data_kwargs: dict = None, **kwargs)[source]#

Plot a 2-D histogram of samples.

Parameters:
  • x – Samples for the horizontal axis.

  • y – Samples for the vertical axis.

  • figmatplotlib.Figure to which the colour-bar axes are added.

  • bins – Number of bins for the 2-D histogram.

  • range – Axis ranges [[x_min, x_max], [y_min, y_max]].

  • weights – Per-sample weights.

  • levels – Contour levels to draw.

  • smooth – Standard deviation for Gaussian kernel smoothing.

  • axmatplotlib.Axes instance on which to draw. Defaults to the current active axes.

  • colormatplotlib colour for the plot elements.

  • plot_datapoints – If True, draw the individual data points.

  • plot_density – If True, render the density colour map.

  • plot_contours – If True, draw the contour lines.

  • no_fill_contours – If True, suppress the white fill beneath contours.

  • fill_contours – If True, fill the contours.

  • contour_kwargs – Extra keyword arguments forwarded to axes.contour.

  • contourf_kwargs – Extra keyword arguments forwarded to axes.contourf.

  • data_kwargs – Extra keyword arguments forwarded to axes.plot when drawing the individual data points.

curepy.utilities.plotting.plot_corner(xs, bins: int = 20, range=None, weights=None, color: str = 'k', smooth=None, smooth1d=None, ticks=None, ticklabels=None, labels=None, label_kwargs: dict = None, show_titles: bool = False, title_fmt: str = '.2f', title_kwargs: dict = None, truths=None, truth_color: str = '#4682b4', scale_hist: bool = False, quantiles=None, verbose: bool = False, fig=None, max_n_ticks: int = 5, top_ticks: bool = False, use_math_text: bool = False, hist_kwargs: dict = None, **hist2d_kwargs)[source]#

Make a corner plot showing the projections of a data set in a multi-dimensional space. Remaining keyword arguments are forwarded to hist2d() or used for matplotlib styling.

Parameters:
  • xs – The samples. Must be a 1-D or 2-D array where the zeroth axis is the list of samples and the next axis are the dimensions of the space.

  • bins – Number of bins to use in histograms, either as a fixed value for all dimensions or as a list of integers for each dimension.

  • range – A list where each element is either a length-2 tuple containing lower and upper bounds, or a float in (0, 1) giving the fraction of samples to include in the bounds.

  • weights – The weight of each sample. If None (default), samples are given equal weight.

  • color – A matplotlib colour for all histograms.

  • smooth – Standard deviation for Gaussian kernel smoothing of the 2-D histograms. None disables smoothing.

  • smooth1d – Standard deviation for Gaussian kernel smoothing of the 1-D histograms. None disables smoothing.

  • ticks – Custom tick positions for each dimension.

  • ticklabels – Custom tick labels for each dimension.

  • labels – A list of names for the dimensions. Defaults to DataFrame column names when xs is a pandas.DataFrame.

  • label_kwargs – Extra keyword arguments passed to set_xlabel / set_ylabel.

  • show_titles – If True, display the 0.5 quantile with 1-sigma errors as a title above each 1-D histogram.

  • title_fmt – Format string for quantile values in titles.

  • title_kwargs – Extra keyword arguments passed to set_title.

  • truths – Reference values to indicate on the plots. Individual values may be None.

  • truth_colormatplotlib colour for the truth markers.

  • scale_hist – If True, scale 1-D histograms so the zero line is visible.

  • quantiles – Fractional quantiles to show as vertical dashed lines on 1-D histograms.

  • verbose – If True, print the computed quantile values.

  • fig – Existing matplotlib.Figure to overplot onto.

  • max_n_ticks – Maximum number of axis ticks per axis.

  • top_ticks – If True, label ticks at the top of each axis.

  • use_math_text – If True, render very large or small axis tick exponents as powers of 10.

  • hist_kwargs – Extra keyword arguments forwarded to the 1-D histogram plots.

Returns:

The matplotlib.Figure containing the corner plot.

curepy.utilities.plotting.quantile(x, q, weights=None)[source]#

Compute sample quantiles with support for weighted samples.

Note

When weights is None, this method simply calls numpy.percentile() with the values of q multiplied by 100.

Parameters:
  • x – The samples.

  • q – The list of quantiles to compute. All values must be in the range [0, 1].

  • weights – An optional weight corresponding to each sample.

Returns:

The sample quantiles computed at q.

Raises:

ValueError – If any value in q is outside [0, 1], or if the lengths of x and weights do not match.