Bar plots

Inherits from PlotChecker.

class plotchecker.BarPlotChecker(axis)[source]

A plot checker for bar plots.

Parameters:

axis : matplotlib.axes.Axes object

A set of matplotlib axes (e.g. obtained through plt.gca())

assert_num_bars(num_bars)[source]

Assert that the plot has the given number of bars.

Parameters:num_bars : int
centers

The centers of the plotted bars.

assert_centers_equal(centers)[source]

Assert that the given centers are equivalent to the plotted centers.

Parameters:

centers : 1-D array-like

The expected centers. The number of elements should be equal to the (expected) number of plotted bars, or just a single value (which will then be applied to all bars).

assert_centers_allclose(centers, **kwargs)[source]

Assert that the given centers are almost equal to the plotted centers.

Parameters:

centers : 1-D array-like

The expected centers. The number of elements should be equal to the (expected) number of plotted bars, or just a single value (which will then be applied to all bars).

kwargs :

Additional keyword arguments to pass to numpy.testing.assert_allclose

heights

The heights of the plotted bars.

assert_heights_equal(heights)[source]

Assert that the given heights are equivalent to the plotted heights.

Parameters:

heights : 1-D array-like

The expected heights. The number of elements should be equal to the (expected) number of plotted bars, or just a single value (which will then be applied to all bars).

assert_heights_allclose(heights, **kwargs)[source]

Assert that the given heights are almost equal to the plotted heights.

Parameters:

heights : 1-D array-like

The expected heights. The number of elements should be equal to the (expected) number of plotted bars, or just a single value (which will then be applied to all bars).

kwargs :

Additional keyword arguments to pass to numpy.testing.assert_allclose

widths

The widths of the plotted bars.

assert_widths_equal(widths)[source]

Assert that the given widths are equivalent to the plotted widths.

Parameters:

widths : 1-D array-like

The expected widths. The number of elements should be equal to the (expected) number of plotted bars, or just a single value (which will then be applied to all bars).

assert_widths_allclose(widths, **kwargs)[source]

Assert that the given widths are almost equal to the plotted widths.

Parameters:

widths : 1-D array-like

The expected widths. The number of elements should be equal to the (expected) number of plotted bars, or just a single value (which will then be applied to all bars).

kwargs :

Additional keyword arguments to pass to numpy.testing.assert_allclose

bottoms

The y-coordinates of the bottoms of the plotted bars.

assert_bottoms_equal(bottoms)[source]

Assert that the given bottoms are equivalent to the plotted bottoms.

Parameters:

bottoms : 1-D array-like

The expected bottoms. The number of elements should be equal to the (expected) number of plotted bars, or just a single value (which will then be applied to all bars).

assert_bottoms_allclose(bottoms, **kwargs)[source]

Assert that the given bottoms are almost equal to the plotted bottoms.

Parameters:

bottoms : 1-D array-like

The expected bottoms. The number of elements should be equal to the (expected) number of plotted bars, or just a single value (which will then be applied to all bars).

kwargs :

Additional keyword arguments to pass to numpy.testing.assert_allclose

colors

The colors of the plotted bars.

assert_colors_equal(colors)[source]

Assert that the given colors are equivalent to the plotted colors.

Parameters:

colors : single color, or list of expected colors

Each color can be either a matplotlib color name (e.g. 'r' or 'red'), a hexcode (e.g. "#FF0000"), a 3-tuple RGB color, or a 4-tuple RGBA color.

assert_colors_allclose(colors, **kwargs)[source]

Assert that the given colors are almost equal to the plotted colors.

Parameters:

colors : single color, or list of expected edge colors

Each color can be either a matplotlib color name (e.g. 'r' or 'red'), a hexcode (e.g. "#FF0000"), a 3-tuple RGB color, or a 4-tuple RGBA color.

kwargs :

Additional keyword arguments to pass to numpy.testing.assert_allclose

edgecolors

The edge colors of the plotted bars.

assert_edgecolors_equal(edgecolors)[source]

Assert that the given edgecolors are equivalent to the plotted edgecolors.

Parameters:

edgecolors : single color, or list of expected edge colors

Each color can be either a matplotlib color name (e.g. 'r' or 'red'), a hexcode (e.g. "#FF0000"), a 3-tuple RGB color, or a 4-tuple RGBA color.

assert_edgecolors_allclose(edgecolors, **kwargs)[source]

Assert that the given edgecolors are almost equal to the plotted edgecolors.

Parameters:

edgecolors : single color, or list of expected edge colors

Each color can be either a matplotlib color name (e.g. 'r' or 'red'), a hexcode (e.g. "#FF0000"), a 3-tuple RGB color, or a 4-tuple RGBA color.

kwargs :

Additional keyword arguments to pass to numpy.testing.assert_allclose

alphas

The alpha values of the plotted bars.

assert_alphas_equal(alphas)[source]

Assert that the given alphas are equivalent to the plotted alphas.

Parameters:

alphas : 1-D array-like

The expected alphas. The number of elements should be equal to the (expected) number of plotted bars, or just a single value (which will then be applied to all bars).

assert_alphas_allclose(alphas, **kwargs)[source]

Assert that the given alphas are almost equal to the plotted alphas.

Parameters:

alphas : 1-D array-like

The expected alphas. The number of elements should be equal to the (expected) number of plotted bars, or just a single value (which will then be applied to all bars).

kwargs :

Additional keyword arguments to pass to numpy.testing.assert_allclose

linewidths

The line widths of the plotted bars.

assert_linewidths_equal(linewidths)[source]

Assert that the given linewidths are equivalent to the plotted linewidths.

Parameters:

linewidths : 1-D array-like

The expected linewidths. The number of elements should be equal to the (expected) number of plotted bars, or just a single value (which will then be applied to all bars).

assert_linewidths_allclose(linewidths, **kwargs)[source]

Assert that the given linewidths are almost equal to the plotted linewidths.

Parameters:

linewidths : 1-D array-like

The expected linewidths. The number of elements should be equal to the (expected) number of plotted bars, or just a single value (which will then be applied to all bars).

kwargs :

Additional keyword arguments to pass to numpy.testing.assert_allclose