bag.data.plot

This module contains utilities to improve waveform plotting in python.

Module Contents

Classes

WaveformPlotter

A custom matplotlib interactive plotting class.

MarkerFigure

Functions

figure(fig_id[, picker])

Create a WaveformPlotter.

plot_waveforms(xvec, panel_list[, fig])

Plot waveforms in vertical panels with shared X axis.

_fpart(x)

_rfpart(x)

draw_line(x0, y0, x1, y1, xmax, grid)

Draws an anti-aliased line in img from p1 to p2 with the given color.

plot_eye_heatmap(fig, tvec, yvec, tper[, tstart, ...])

Plot eye diagram heat map.

plot_eye(fig, tvec, yvec_list, tper[, tstart, tend, ...])

Plot eye diagram.

_find_closest_point(x, y, xvec, yvec, xnorm, ynorm)

Find point on PWL waveform described by xvec, yvec closest to (x, y)

Attributes

color_cycle

bag.data.plot.color_cycle = ['#1f77b4', '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2', '#7f7f7f',...[source]
bag.data.plot.figure(fig_id, picker=5.0)[source]

Create a WaveformPlotter.

Parameters:
  • fig_id (int) – the figure ID.

  • picker (float) – picker event pixel tolerance.

Returns:

plotter – a plotter that helps you make interactive matplotlib figures.

Return type:

bag.data.plot.WaveformPlotter

bag.data.plot.plot_waveforms(xvec, panel_list, fig=1)[source]

Plot waveforms in vertical panels with shared X axis.

Parameters:
  • xvec (numpy.ndarray) – the X data.

  • panel_list (list[list[(str, numpy.ndarray)]]) – list of lists of Y data. Each sub-list is one panel. Each element of the sub-list is a tuple of signal name and signal data.

  • fig (int) – the figure ID.

bag.data.plot._fpart(x)[source]
bag.data.plot._rfpart(x)[source]
bag.data.plot.draw_line(x0, y0, x1, y1, xmax, grid)[source]

Draws an anti-aliased line in img from p1 to p2 with the given color.

bag.data.plot.plot_eye_heatmap(fig, tvec, yvec, tper, tstart=None, tend=None, toff=None, tstep=None, vstep=None, cmap=None, vmargin=0.05, interpolation='gaussian', repeat=False)[source]

Plot eye diagram heat map.

Parameters:
  • fig (int) – the figure ID.

  • tvec (np.ndarray) – the time data.

  • yvec (np.ndarray) – waveform data.

  • tper (float) – the eye period.

  • tstart (float) – starting time. Defaults to first point.

  • tend (float) – ending time. Defaults to last point.

  • toff (float) – eye offset. Defaults to 0.

  • tstep (float or None) – horizontal bin size. Defaults to using 200 bins.

  • vstep (float or None) – vertical bin size. Defaults to using 200 bins.

  • cmap – the colormap used for coloring the heat map. If None, defaults to cubehelix_r

  • vmargin (float) – vertical margin in percentage of maximum/minimum waveform values. Defaults to 5 percent. This is used so that there some room between top/bottom of eye and the plot.

  • interpolation (str) – interpolation method. Defaults to ‘gaussian’. Use ‘none’ for no interpolation.

  • repeat (bool) – True to repeat the eye diagram once to the right. This is useful if you want to look at edge transistions.

bag.data.plot.plot_eye(fig, tvec, yvec_list, tper, tstart=None, tend=None, toff_list=None, name_list=None, alpha=1.0)[source]

Plot eye diagram.

Parameters:
  • fig (int) – the figure ID.

  • tvec (np.ndarray) – the time data.

  • yvec_list (list[np.ndarray]) – list of waveforms to plot in eye diagram.

  • tper (float) – the period.

  • tstart (float) – starting time. Defaults to first point.

  • tend (float) – ending time. Defaults to last point.

  • toff_list (list[float]) – offset to apply to each waveform. Defaults to zeros.

  • name_list (list[str] or None) – the name of each waveform. Defaults to numbers.

  • alpha (float) – the transparency of each trace. Can be used to mimic heatmap.

bag.data.plot._find_closest_point(x, y, xvec, yvec, xnorm, ynorm)[source]

Find point on PWL waveform described by xvec, yvec closest to (x, y)

class bag.data.plot.WaveformPlotter(fig_idx, picker=5.0, normal_width=1.5, select_width=3.0)[source]

Bases: object

A custom matplotlib interactive plotting class.

This class adds many useful features, such as ability to add/remove markers, ability to toggle waveforms on and off, and so on.

Parameters:
  • fig_idx (int) – the figure index.

  • picker (float) – picker event pixel tolerance.

  • normal_width (float) – normal linewidth.

  • select_width (float) – selected linewidth.

plot(*args, **kwargs)[source]
setup()[source]
figure_closed(event)[source]
figure_resized(event)[source]
fix_legend_location(event)[source]
legend_line_picked(artist)[source]
legend_text_picked(artist, draw=True)[source]
class bag.data.plot.MarkerFigure(**kwargs)[source]

Bases: matplotlib.figure.Figure

set_line_visibility(axline, visible)[source]
register_pick_event(artist_set, fun)[source]
on_button_release(event)[source]

Disable data cursor dragging.

on_motion(event)[source]

Move data cursor around.

_get_idx_under_point(event)[source]

Find selected data cursor.

on_pick(event)[source]
_create_marker()[source]
close_figure()[source]
setup_callbacks()[source]