plot_1D_dist

legwork.visualisation.plot_1D_dist(x, weights=None, disttype='hist', log_scale=False, fig=None, ax=None, show=True, figsize=(10, 7), xlabel=None, ylabel=None, xlim=None, ylim=None, color=None, **kwargs)[source]

Plot a 1D distribution of x.

This function is a wrapper for matplotlib.pyplot.hist(), seaborn.kdeplot() and seaborn.ecdfplot().

Parameters
xfloat/int array

Variable to plot, should be a 1D array

weightsfloat/int array

Weights for each variable in x, must have the same shape

disttype{{ “hist”, “kde”, “ecdf” }}

Which type of distribution plot to use

log_scalebool

Whether to plot log10(x) instead of x

fig: `matplotlib Figure`

A figure on which to plot the distribution. Both ax and fig must be supplied for either to be used

ax: `matplotlib Axis`

An axis on which to plot the distribution. Both ax and fig must be supplied for either to be used

showboolean

Whether to immediately show the plot or only return the Figure and Axis

figsizetuple

Tuple with size for the x- and y-axis if creating a new figure (i.e. ignored when fig/ax is not None)

xlabelstring

Label for the x axis, passed to Axes.set_xlabel()

ylabelstring

Label for the y axis, passed to Axes.set_ylabel()

xlimtuple

Lower and upper limits for the x axis, passed to Axes.set_xlim()

ylimtuple

Lower and upper limits for the y axis, passed to Axes.set_ylim()

colorstring or tuple

Colour to use for the plot, see https://matplotlib.org/tutorials/colors/colors.html for details on how to specify a colour

**kwargs(if disttype==”hist”)

Include values for any of bins, range, density, cumulative, bottom, histtype, align, orientation, rwidth, log, label or more. See matplotlib.pyplot.hist() for more details.

**kwargs(if disttype==”kde”)

Include values for any of gridsize, cut, clip, legend, cumulative, bw_method, bw_adjust, log_scale, fill, label, linewidth, linestyle or more. See seaborn.kdeplot() for more details.

**kwargs(if disttype==”ecdf”)

Include values for any of stat, complementary, log_scale, legend, label, linewidth, linestyle or more. See seaborn.edcfplot() for more details.

Returns
figmatplotlib Figure

The figure on which the distribution is plotted

axmatplotlib Axis

The axis on which the distribution is plotted