skbio.draw.distributions.grouped_distributions

skbio.draw.distributions.grouped_distributions(plot_type, data, x_values=None, data_point_labels=None, distribution_labels=None, distribution_markers=None, x_label=None, y_label=None, title=None, x_tick_labels_orientation='vertical', y_min=None, y_max=None, whisker_length=1.5, error_bar_type='stdv', distribution_width=None, figure_width=None, figure_height=None)[source]

Generate a figure with distributions grouped at points along the x-axis.

Parameters:

plot_type : {‘bar’, ‘scatter’, ‘box’}

Type of plot to visualize distributions with.

data : list of lists of lists

Each inner list represents a data point along the x-axis. Each data point contains lists of data for each distribution in the group at that point. This nesting allows for the grouping of distributions at each data point.

x_values : list of scalars, optional

Spacing of data points along the x-axis. Must be the same length as the number of data points and be in ascending sorted order. If not provided, plots will be spaced evenly.

data_point_labels : list of str, optional

Labels for data points.

distribution_labels : list of str, optional

Labels for each distribution in a data point grouping.

distribution_markers : list of str or list of tuple, optional

Matplotlib-compatible strings or tuples that indicate the color or symbol to be used to distinguish each distribution in a data point grouping. Colors will be used for bar charts or box plots, while symbols will be used for scatter plots.

x_label : str, optional

x-axis label.

y_label : str, optional

y-axis label.

title : str, optional

Plot title.

x_tick_labels_orientation : {‘vertical’, ‘horizontal’}

Orientation of x-axis labels.

y_min : scalar, optional

Minimum value of the y-axis. If None, uses matplotlib’s autoscale.

y_max : scalar, optional

Maximum value of the y-axis. If None, uses matplotlib’s autoscale.

whisker_length : scalar, optional

If plot_type is 'box', determines the length of the whiskers as a function of the IQR. For example, if 1.5, the whiskers extend to 1.5 * IQR. Anything outside of that range is seen as an outlier. If plot_type is not 'box', this parameter is ignored.

error_bar_type : {‘stdv’, ‘sem’}

Type of error bars to use if plot_type is 'bar'. Can be either 'stdv' (for standard deviation) or 'sem' for the standard error of the mean. If plot_type is not 'bar', this parameter is ignored.

distribution_width : scalar, optional

Width in plot units of each individual distribution (e.g. each bar if the plot type is a bar chart, or the width of each box if the plot type is a boxplot). If None, will be automatically determined.

figure_width : scalar, optional

Width of the plot figure in inches. If not provided, will default to matplotlib’s default figure width.

figure_height : scalar, optional

Height of the plot figure in inches. If not provided, will default to matplotlib’s default figure height.

Returns:

matplotlib.figure.Figure

Figure containing distributions grouped at points along the x-axis.

Examples

Create a plot with two distributions grouped at three points:

>>> from skbio.draw.distributions import grouped_distributions
>>> fig = grouped_distributions('bar',
...                             [[[2, 2, 1,], [0, 1, 4]],
...                             [[1, 1, 1], [4, 4.5]],
...                             [[2.2, 2.4, 2.7, 1.0], [0, 0.2]]],
...                             distribution_labels=['Treatment 1',
...                                                  'Treatment 2'])

(Source code, png, hires.png, pdf)

../_images/skbio-draw-distributions-grouped_distributions-1.png