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.
fig –
matplotlib.Figureto 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.
ax –
matplotlib.Axesinstance on which to draw. Defaults to the current active axes.color –
matplotlibcolour 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.plotwhen 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 formatplotlibstyling.- 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
matplotlibcolour for all histograms.smooth – Standard deviation for Gaussian kernel smoothing of the 2-D histograms.
Nonedisables smoothing.smooth1d – Standard deviation for Gaussian kernel smoothing of the 1-D histograms.
Nonedisables 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
DataFramecolumn names whenxsis apandas.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_color –
matplotlibcolour 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.Figureto 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.Figurecontaining the corner plot.
- curepy.utilities.plotting.quantile(x, q, weights=None)[source]#
Compute sample quantiles with support for weighted samples.
Note
When
weightsisNone, this method simply callsnumpy.percentile()with the values ofqmultiplied 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
qis outside[0, 1], or if the lengths ofxandweightsdo not match.