# Visualizations¶

Helper functions to visualize results of ABCSMC runs.

pyabc.visualization.kde_1d(df, w, x, xmin=None, xmax=None, numx=50)

Calculates a 1 dimensional histogram from a Dataframe and weights.

For example, a results distribution might be obtained from the history class and plotted as follows:

df, w = history.get_distribution(0)
x, pdf = hist_2d(df, w, "x")
plt.plot(x, pdf)

Parameters: df (Pandas Dataframe) – The rows are the observations, the columns the variables w (np.ndarray) – The corresponding weights x (str) – The variable for the x-axis xmin (float, optional) – The lower limit in x for the histogram. If left empty, it is set to the minimum of the ovbservations of the variable to be plotted as x. xmax (float, optional) – The upper limit in x for the histogram. If left empty, it is set to the maximum of the ovbservations of the variable to be plotted as x. numx (int, optional) – The number of bins in x direction. Defaults tp 50. x, pdf – The x and the densities at these points. These can be passed for plotting, for example as plt.plot(x, pdf) (np.ndarray, np.ndarray)
pyabc.visualization.kde_2d(df, w, x, y, xmin=None, xmax=None, ymin=None, ymax=None, numx=50, numy=50)

Calculates a 2 dimensional histogram from a Dataframe and weights.

For example, a results distribution might be obtained from the history class and plotted as follows:

df, w = history.get_distribution(0)
X, Y, PDF = hist_2d(df, w, "x", "y")
plt.pcolormesh(X, Y, PDF)

Parameters: df (Pandas Dataframe) – The rows are the observations, the columns the variables w (The corresponding weights) – x (str) – The variable for the x-axis y (str) – The variable for the y-axis xmin (float, optional) – The lower limit in x for the histogram. If left empty, it is set to the minimum of the ovbservations of the variable to be plotted as x. xmax (float, optional) – The upper limit in x for the histogram. If left empty, it is set to the maximum of the ovbservations of the variable to be plotted as x. ymin (float, optional) – The lower limit in y for the histogram. If left empty, it is set to the minimum of the ovbservations of the variable to be plotted as y ymax (float, optional) – The upper limit in y for the histogram. If left empty, it is set to the maximum of the ovbservations of the variable to be plotted as y. numx (int, optional) – The number of bins in x direction. Defaults tp 50. int, optional (numy) – The number of bins in y direction. Defaults tp 50. X, Y, PDF – The X, the Y and the densities at these points. These can be passed for plotting, for example as plt.pcolormesh(X, Y, PDF) (np.ndarray, np.ndarray, np.ndarray)
pyabc.visualization.plot_kde_1d(df, w, x, xmin=None, xmax=None, numx=50, ax=None, **kwargs)

Plots a 1d histogram.

Parameters: df (Pandas Dataframe) – The rows are the observations, the columns the variables w (The corresponding weights) – x (str) – The variable for the x-axis xmin (float, optional) – The lower limit in x for the histogram. If left empty, it is set to the minimum of the ovbservations of the variable to be plotted as x. xmax (float, optional) – The upper limit in x for the histogram. If left empty, it is set to the maximum of the ovbservations of the variable to be plotted as x. numx (int, optional) – The number of bins in x direction. Defaults tp 50. ax – axis of the plot matplotlib axis
pyabc.visualization.plot_kde_2d(df, w, x, y, xmin=None, xmax=None, ymin=None, ymax=None, numx=50, numy=50, ax=None, colorbar=True, title=True, **kwargs)

Plots a 2d histogram.

Parameters: df (Pandas Dataframe) – The rows are the observations, the columns the variables w (The corresponding weights.) – x (str) – The variable for the x-axis. y (str) – The variable for the y-axis. xmin (float, optional) – The lower limit in x for the histogram. If left empty, it is set to the minimum of the ovbservations of the variable to be plotted as x. xmax (float, optional) – The upper limit in x for the histogram. If left empty, it is set to the maximum of the ovbservations of the variable to be plotted as x. ymin (float, optional) – The lower limit in y for the histogram. If left empty, it is set to the minimum of the ovbservations of the variable to be plotted as y. ymax (float, optional) – The upper limit in y for the histogram. If left empty, it is set to the maximum of the ovbservations of the variable to be plotted as y. numx (int, optional) – The number of bins in x direction. Defaults to 50. int, optional (numy) – The number of bins in y direction. Defaults tp 50. colorbar (bool, optional) – Whether to plot a colorbar. Defaults to True. title (bool, optional) – Whether to put a title on the plot. Defaults to True. ax – axis of the plot matplotlib axis
pyabc.visualization.plot_kde_matrix(df, w, limits=None, colorbar=True)

Plot a KDE matrix.

Parameters: df (Pandas Dataframe) – The rows are the observations, the columns the variables. w (np.narray) – The corresponding weights. colorbar (bool) – Whether to plot the colorbars or not. limits (dictionary, optional) – Dictionary of the form {"name": (lower_limit, upper_limit)}.