Plotter

class stonesoup.plotter.Dimension(value)[source]

Dimension Enum class for specifying plotting parameters in the Plotter class. Used to sanitize inputs for the dimension attribute of Plotter().

TWO

Specifies 2D plotting for Plotter object

Type

str

THREE

Specifies 3D plotting for Plotter object

Type

str

class stonesoup.plotter.Plotter(dimension=Dimension.TWO)[source]

Plotting class for building graphs of Stone Soup simulations

A plotting class which is used to simplify the process of plotting ground truths, measurements, clutter and tracks. Tracks can be plotted with uncertainty ellipses or particles if required. Legends are automatically generated with each plot. Three dimensional plots can be created using the optional dimension parameter.

Parameters

dimension (enum 'Dimension') – Optional parameter to specify 2D or 3D plotting. Default is 2D plotting.

fig

Generated figure for graphs to be plotted on

Type

matplotlib.figure.Figure

ax

Generated axes for graphs to be plotted on

Type

matplotlib.axes.Axes

legend_dict

Dictionary of legend handles as matplotlib.legend_handler.HandlerBase and labels as str

Type

dict

plot_ground_truths(truths, mapping, truths_label='Ground Truth', **kwargs)[source]

Plots ground truth(s)

Plots each ground truth path passed in to truths and generates a legend automatically. Ground truths are plotted as dashed lines with default colors.

Users can change linestyle, color and marker using keyword arguments. Any changes will apply to all ground truths.

Parameters
  • truths (set of GroundTruthPath) – Set of ground truths which will be plotted. If not a set, and instead a single GroundTruthPath type, the argument is modified to be a set to allow for iteration.

  • mapping (list) – List of items specifying the mapping of the position components of the state space.

  • **kwargs (dict) – Additional arguments to be passed to plot function. Default is linestyle="--".

plot_measurements(measurements, mapping, measurement_model=None, measurements_label='Measurements', **kwargs)[source]

Plots measurements

Plots detections and clutter, generating a legend automatically. Detections are plotted as blue circles by default unless the detection type is clutter. If the detection type is Clutter it is plotted as a yellow ‘tri-up’ marker.

Users can change the color and marker of detections using keyword arguments but not for clutter detections.

Parameters
  • measurements (list of Detection) – Detections which will be plotted. If measurements is a set of lists it is flattened.

  • mapping (list) – List of items specifying the mapping of the position components of the state space.

  • measurement_model (Model, optional) – User-defined measurement model to be used in finding measurement state inverses if they cannot be found from the measurements themselves.

  • **kwargs (dict) – Additional arguments to be passed to plot function for detections. Defaults are marker='o' and color='b'.

plot_tracks(tracks, mapping, uncertainty=False, particle=False, track_label='Track', err_freq=1, **kwargs)[source]

Plots track(s)

Plots each track generated, generating a legend automatically. If uncertainty=True and is being plotted in 2D, error elipses are plotted. If being plotted in 3D, uncertainty bars are plotted every err_freq measurement, default plots unceratinty bars at every track step. Tracks are plotted as solid lines with point markers and default colors. Uncertainty bars are plotted with a default color which is the same for all tracks.

Users can change linestyle, color and marker using keyword arguments. Uncertainty metrics will also be plotted with the user defined colour and any changes will apply to all tracks.

Parameters
  • tracks (set of Track) – Set of tracks which will be plotted. If not a set, and instead a single Track type, the argument is modified to be a set to allow for iteration.

  • mapping (list) – List of items specifying the mapping of the position components of the state space.

  • uncertainty (bool) – If True, function plots uncertainty ellipses or bars.

  • particle (bool) – If True, function plots particles.

  • track_label (str) – Label to apply to all tracks for legend.

  • err_freq (int) – Frequency of error bar plotting on tracks. Default value is 1, meaning error bars are plotted at every track step.

  • **kwargs (dict) – Additional arguments to be passed to plot function. Defaults are linestyle="-", marker='.' and color=None.

static ellipse_legend(ax, label_list, color_list, **kwargs)[source]

Adds an ellipse patch to the legend on the axes. One patch added for each item in label_list with the corresponding color from color_list.

Parameters
  • ax (matplotlib.axes.Axes) – Looks at the plot axes defined

  • label_list (list of str) – Takes in list of strings intended to label ellipses in legend

  • color_list (list of str) – Takes in list of colors corresponding to string/label Must be the same length as label_list

  • **kwargs (dict) – Additional arguments to be passed to plot function. Default is alpha=0.2.