zabgrab.ui.plot

Drawing plots with matplotlib (the optional plot extra).

matplotlib is imported only when a plot is drawn, so zabgrab works without it.

Module Attributes

REFERENCE_STYLES

Dash patterns for reference lines, so several are told apart in the legend.

Functions

draw(spec, tz, *[, interactive])

Draw a plot.

draw_histogram(spec, *[, interactive])

Draw a histogram: bins along the bottom, counts up the side.

show_or_save(spec, tz[, outputs])

Show a plot in a window, or save it to files.

zabgrab.ui.plot.draw(spec, tz, *, interactive=False)[source]

Draw a plot.

Parameters:
Returns:

matplotlib.figure.Figure – One subplot per axis in spec, sharing the time axis.

Return type:

Figure

zabgrab.ui.plot.draw_histogram(spec, *, interactive=False)[source]

Draw a histogram: bins along the bottom, counts up the side.

The bins are drawn the same width, labelled with their ranges, lowest on the left: the first and last are open-ended, and the others’ real widths can differ by orders of magnitude. Each series’ bars sit side by side in each bin. Values run along the bottom, so vertical reference lines are drawn across the bins at values, and horizontal ones through the bars at counts.

Parameters:
Returns:

matplotlib.figure.Figure – One subplot per axis in spec.

Return type:

Figure

zabgrab.ui.plot.REFERENCE_STYLES = ['--', ':', '-.', (0, (8, 3, 2, 3, 2, 3))]

Dash patterns for reference lines, so several are told apart in the legend.

zabgrab.ui.plot.show_or_save(spec, tz, outputs=())[source]

Show a plot in a window, or save it to files.

Parameters:
  • spec (PlotSpec or HistogramSpec) – What to draw: lines over time, or a histogram.

  • tz (tzinfo or None) – The time zone to show times in (None for local time).

  • outputs (sequence of Path, optional) – The image files to save to (each one’s extension picks its format, e.g. .png, .pdf or .svg). If none are given, the plot is shown in a window.

Raises:

ZabgrabError – If matplotlib isn’t installed, or a file can’t be written.

Return type:

None