Plot Elements

Plot elements in Boomslang are represented by objects that encapsulate all the state that a plot element needs to draw itself. The one required method that all plot elements must implement is draw(self, fig, axes), which the element uses to draw itself within the figure fig on the axes axes.

PlotInfo: The Common Plot Element Base Class

Many of Boomslang’s plot elements inherit from PlotInfo. PlotInfo contains several useful fields (x-axis and y-axis values, error bars, etc.)

class boomslang.PlotInfo.PlotInfo(plotType, xValues=None, yValues=None, xTickLabels=None, yTickLabels=None, xTickLabelPoints=None, yTickLabelPoints=None, xTickLabelProperties=None, yTickLabelProperties=None, label=None, yMins=None, yMaxes=None, yErrors=None, autosort=True, xLimits=None, errorBarColor=None, errorBarLineWidth=None, errorBarCapsize=None, picker=None)
autosort = None

If true, x/y pairs in xValues and yValues are sorted by x value before the plot is rendered

draw(fig, axis, transform=None)

The base method for drawing a plot element on the axis axis within the figure fig. Other plot elements should override this method, but should also be sure to call this method before doing any element-specific processing.

drawErrorBars(axis, transform=None)

Draw error bars for the plot element using the plot element’s yMins/yMaxes or yErrors. If yMins or yMaxes have non-zero length, they are used to draw error bars that can be asymmetric. Otherwise, yErrors are used to draw symmetric error bars.

If some transform should be applied to the error bars, it is provided by the caller with the transform parameter.

getAttributes()

Get the attributes dictionary used to style the plot element. Extending this method allows plot elements to inherit attributes.

label = None

A string used to label this plot element in a legend

plotType = None

Names the type of plot element

split(pieces)

Split this plot element into pieces separate plot elements, each of which is responsible for a disjoint range of the original plot element’s x-axis. This is useful for situations where a plot element cannot fit comfortably in a single plot.

xTickLabelPoints = None

The locations on the x-axis where the labels in xTickLabels should be drawn

xTickLabelProperties

A dictionary of properties that control the appearance of the X axis’ tick labels. See Labels for more information on which properties can be set.

xTickLabels = None

A list of labels that should be drawn on the x-axis

xValues = None

An array of x-axis values for the plot element

yErrors = None

For symmetric error bars, a list of error bar widths for this plot element’s error bars

yMaxes = None

For asymmetric error bars, a list of locations for the tops of this plot element’s error bars

yMins = None

For asymmetric error bars, a list of locations for the bottoms of this plot element’s error bars

yTickLabelPoints = None

The locations on the x-axis where the labels in xTickLabels should be drawn

yTickLabelProperties

A dictionary of properties that control the appearance of the Y axis’ tick labels. See Labels for more information on which properties can be set.

yTickLabels = None

A list of labels that should be drawn on the y-axis

yValues = None

An array of y-axis values for the plot elements

Simple Plot Elements

Boomslang comes equipped with the standard plot elements for making lines, bar graphs, scatter plots, and box-and-whisker plots.

class boomslang.Line.Line(color='black', width=1, lineStyle='-', marker=None, markerSize=8.0, dates=False, loglog=False, steps=None, alpha=None, antialiased=False, **kwargs)

A plot element that represents a line in two-dimensional space

antialiased = None

If True, the line will be anti-aliased, removing jagged edges in some output formats

color = None

The line’s color. see Colors for valid colors.

dates = None

If True, the x-axis values of this line will be interpreted as dates

lineStyle

The line’s style. See Line Styles for more information about available line styles.

lineWidth = None

The line’s width

marker

The marker used to mark points on the line. See Markers for more information on avialable marker types.

markerSize

The size of the markers used to mark points on the line.

steps

If not None, the line will be plotted as a step function. If “pre”, each point comes before a step. If “mid”, each point is in the middle of a step. If “post”, each point comes after a step.

class boomslang.HLine.HLine(marker=None, markerSize=8.0, width=1.0, color='black', lineStyle='-', dates=False, **kwargs)

A plot element that represents a horizontal line that passes through a given point on the y-axis.

color = None

The line’s color. See Colors for valid colors.

lineStyle

The line style for this line; see Line Styles for more information about available line styles.

marker

The marker used to mark points on the line. See Markers for more information about available markers.

markerSize

The size of this line’s markers.

width = None

The line’s width

class boomslang.VLine.VLine(marker=None, markerSize=8.0, width=1.0, color='black', lineStyle='-', dates=False, **kwargs)
color = None

The line’s color. See Colors for valid colors.

lineStyle

The line style for this line; see Line Styles for more information about available line styles.

marker

The marker used to mark points on the line. See Markers for more information about available markers.

markerSize

The size of this line’s markers.

width = None

The line’s width

class boomslang.Scatter.Scatter(marker='o', markerSize=20, color='black', **kwargs)
color = None

The color of points in the scatter plot. See Colors for valid colors.

marker

The marker type used to mark points in the scatter plot. See Markers for valid marker types.

markerSize

The size of the scatter plot’s markers.

class boomslang.Bar.Bar(label=None, labelBars=False, width=0.8, linewidth=1.0, color='black', edgeColor=None, hatch=None, align='center', **kwargs)

A bar chart consisting of a single series of bars.

align = None

If center (default), xValues values denote the center of each bar. If edge, xValues values denote the left edge of each bar.

color = None

The color of the bars

edgeColor = None

The color of the line that borders each bar

hatch = None

The style of hatching used within the bar, if any. Valid values are any marker type, /, //, \ and \

linewidth = None

The width of the line that borders each bar

padding = None

Amount of padding between the edge of the left- and rightmost bars and the bounding box for the plot

width = None

The width of each bar in the set of bars

class boomslang.BoxAndWhisker.BoxAndWhisker

A modified box-and-whisker plot.

width = None

The width of each of the element’s “boxes”.

xSequence = None

A list of lists defining the values to be plotted. Each list gives a set of y-axis values. The first list gives the values for x=0, the second for x=1, and so on.

Compound Plot Elements

Boomslang can combine certain plot elements together to easily create stacks and clusters of plot elements while maintaining the individual elements themselves, making it easy to re-compose them by changing a couple of lines of code.

class boomslang.ClusteredBars.ClusteredBars

A clustered bar chart consisting of multiple series of bars with the same X axis values.

add(bar)

Add bar (a boomslang.Bar.Bar) to the cluster of bars

barWidth = None

The width of each bar in the cluster

deduplicateLegend = None

If multiple legend items have the same key, only show the first one

padding = None

Amount of padding between the edge of the left- and rightmost bars and the bounding box for the plot

spacing = None

The spacing between each bar in the cluster

width

The overall width of each cluster of bars

class boomslang.StackedBars.StackedBars

A stacked bar chart consisting of multiple series of bars with the same X axis values

add(bar)

Add bar (a boomslang.Bar.Bar) to the stack

barWidth = None

The width of the bars in the stack

padding = None

Amount of padding between the edge of the left- and rightmost bars and the bounding box for the plot

spacing = None

The spacing between stacks of bars

class boomslang.StackedLines.StackedLines

Lines stacked one atop the other, with colors filling in the gaps

addLine(line, color='white')

Add line (a boomslang.Line.Line) to the stack of lines, coloring the gap between it and the previous line with color

Miscellaneous Plot Elements

class boomslang.Label.Label(x, y, text=None, bbox=None)

Labels a point on the plot with text and/or arrows

hasArrow(style='->', color='black')

Defines an arrow between the label’s text and its point. Valid arrow styles are given in Matplotlib’s documentation.

labelProperties

A dictionary of properties that control the appearance of the label. See Labels for more information on which properties can be set.

marker

The marker type that should be used to mark the labeled point

text = None

The text that should be displayed with the label

x = None

The label’s x coordinate

y = None

The label’s y coordinate