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
Dash patterns for reference lines, so several are told apart in the legend. |
Functions
|
Draw a plot. |
|
Draw a histogram: bins along the bottom, counts up the side. |
|
Show a plot in a window, or save it to files. |
- zabgrab.ui.plot.draw(spec, tz, *, interactive=False)[source]¶
Draw a plot.
- Parameters:
spec (PlotSpec) – What to draw (see
zabgrab.services.plotting.plot_spec()).tz (tzinfo or None) – The time zone to show times in (
Nonefor local time).interactive (bool, optional) – Whether the figure will be shown in a window.
- 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:
spec (HistogramSpec) – What to draw (see
zabgrab.services.plotting.histogram_spec()).interactive (bool, optional) – Whether the figure will be shown in a window.
- 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 (
Nonefor local time).outputs (sequence of Path, optional) – The image files to save to (each one’s extension picks its format, e.g.
.png,.pdfor.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