triangle: auxiliary module to MCMC plotting

PyHdust auxiliary module: third-part MCMC plotting tools.

:co-author:Dan Foreman-Mackey :license: GNU GPL v3.0 https://github.com/danmoser/pyhdust/blob/master/LICENSE

pyhdust.triangle.corner(xs, bins=20, range=None, weights=None, color='k', smooth=None, smooth1d=None, labels=None, label_kwargs=None, show_titles=False, title_fmt='.2f', title_kwargs=None, truths=None, truth_color='#4682b4', scale_hist=False, quantiles=None, verbose=False, fig=None, max_n_ticks=5, top_ticks=False, hist_kwargs=None, qtdiff=None, **hist2d_kwargs)[source]

Make a sick corner plot showing the projections of a data set in a multi-dimensional space. kwargs are passed to hist2d() or used for matplotlib styling.

Parameters:
  • xs (array_like (nsamples, ndim)) – The samples. This should be a 1- or 2-dimensional array. For a 1-D array this results in a simple histogram. For a 2-D array, the zeroth axis is the list of samples and the next axis are the dimensions of the space.

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

  • labels (iterable (ndim,) (optional)) – A list of names for the dimensions. If a xs is a pandas.DataFrame, labels will default to column names.

  • show_titles (bool (optional)) – Displays a title above each 1-D histogram showing the 0.5 quantile with the upper and lower errors supplied by the quantiles argument.

  • title_fmt (string (optional)) – The format string for the quantiles given in titles. (default: .2f)

  • title_args (dict (optional)) – Any extra keyword arguments to send to the add_title command.

  • extents (iterable (ndim,) (optional)) – A list where each element is either a length 2 tuple containing lower and upper bounds (extents) or a float in range (0., 1.) giving the fraction of samples to include in bounds, e.g., [(0.,10.), (1.,5), 0.999, etc.]. If a fraction, the bounds are chosen to be equal-tailed.

  • truths (iterable (ndim,) (optional)) – A list of reference values to indicate on the plots. Individual values can be omitted by using None.

  • truth_color (str (optional)) – A matplotlib style color for the truths makers.

  • scale_hist (bool (optional)) – Should the 1-D histograms be scaled in such a way that the zero line is visible?

  • quantiles (iterable (optional)) – A list of fractional quantiles to show on the 1-D histograms as vertical dashed lines.

  • verbose (bool (optional)) – If true, print the values of the computed quantiles.

  • plot_contours (bool (optional)) – Draw contours for dense regions of the plot.

  • plot_datapoints (bool (optional)) – Draw the individual data points.

  • max_n_ticks (int (optional)) – maximum number of ticks to try to use

  • fig (matplotlib.Figure (optional)) – Overplot onto the provided figure object.

pyhdust.triangle.hist2d(x, y, bins=20, range=None, weights=None, levels=None, smooth=None, ax=None, color=None, plot_datapoints=True, plot_density=True, plot_contours=True, fill_contours=False, contour_kwargs=None, contourf_kwargs=None, data_kwargs=None, **kwargs)[source]

Plot a 2-D histogram of samples.

pyhdust.triangle.kerncorner(xs, cmapn='gray_r', ncl=3, bestvals='perc', labels=[])[source]

xs = (niteractions, ndim) ncl = number os contour lines bestvals = None, ‘peak’ or ‘perc’

pyhdust.triangle.quantile(x, q, weights=None)[source]

Like numpy.percentile, but:

  • Values of q are quantiles [0., 1.] rather than percentiles [0., 100.]

  • scalar q not supported (q must be iterable)

  • optional weights on x