Plotter

class stonesoup.plotter.Dimension(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[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:

int

THREE

Specifies 3D plotting for Plotter object

Type:

int

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

Plotting class for building graphs of Stone Soup simulations using matplotlib

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.

  • plot_timeseries (bool) – Specify whether data to be plotted is time series data. Default False

  • **kwargs (dict) – Additional arguments to be passed to plot function. For example, figsize (Default is (10, 6)).

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, 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 (Collection of GroundTruthPath) – Collection of ground truths which will be plotted. If not a collection 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.

  • label (str) – Label for truth data. Default is “Ground Truth”

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

Returns:

List of artists that have been added to the axis.

Return type:

list of matplotlib.artist.Artist

Deprecated since version 1.5: label has replaced truths_label. In the current implementation truths_label overrides label. However, use of truths_label may be removed in the future.

plot_measurements(measurements, mapping, measurement_model=None, label='Measurements', convert_measurements=True, **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 (Collection 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.

  • label (str) – Label for the measurements. Default is “Measurements”.

  • convert_measurements (bool) – Should the measurements be converted from measurement space to state space before being plotted. Default is True

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

Returns:

List of artists that have been added to the axis.

Return type:

list of matplotlib.artist.Artist

Deprecated since version 1.5: label has replaced measurements_label. In the current implementation measurements_label overrides label. However, use of measurements_label may be removed in the future.

plot_tracks(tracks, mapping, uncertainty=False, particle=False, label='Tracks', err_freq=1, same_color=False, **kwargs)[source]

Plots track(s)

Plots each track generated, generating a legend automatically. If uncertainty=True and is being plotted in 2D, error ellipses are plotted. If being plotted in 3D, uncertainty bars are plotted every err_freq measurement, default plots uncertainty 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 (Collection of Track) – Collection of tracks which will be plotted. If not a collection, 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.

  • 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.

  • same_color (bool) – Should all the tracks have the same color. Default False

  • **kwargs (dict) – Additional arguments to be passed to plot function. Defaults are linestyle="-", marker='s' for Update and marker='o' for other states.

Returns:

List of artists that have been added to the axis.

Return type:

list of matplotlib.artist.Artist

Deprecated since version 1.5: label has replaced track_label. In the current implementation track_label overrides label. However, use of track_label may be removed in the future.

plot_sensors(sensors, mapping=None, label='Sensors', **kwargs)[source]

Plots sensor(s)

Plots sensors. Users can change the color and marker of sensors using keyword arguments. Default is a black ‘x’ marker.

Parameters:
  • sensors (Collection of Sensor) – Sensors to plot

  • mapping (list) – List of items specifying the mapping of the position components of the sensor’s position. Default is either [0, 1] or [0, 1, 2] depending on self.dimension

  • label (str) – Label to apply to all sensors for legend.

  • **kwargs (dict) – Additional arguments to be passed to plot function for sensors. Defaults are marker='x' and color='black'.

Returns:

List of artists that have been added to the axis.

Return type:

list of matplotlib.artist.Artist

Deprecated since version 1.5: label has replaced sensor_label. In the current implementation sensor_label overrides label. However, use of sensor_label may be removed in the future.

set_equal_3daxis(axes=None)[source]

Plots minimum/maximum points with no linestyle to increase the plotting region to simulate .ax.axis(‘equal’) from matplotlib 2d plots which is not possible using 3d projection.

Parameters:

axes (list) – List of dimension index specifying the equal axes, equal x and y = [0,1]. Default is x,y [0,1].

plot_density(state_sequences: Collection[StateMutableSequence], index: int | None = -1, mapping=(0, 2), n_bins=300, **kwargs)[source]
Parameters:
  • state_sequences (a collection of StateMutableSequence) – 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.

  • index (int) – Which index of the StateMutableSequences should be plotted. Default value is ‘-1’ which is the last state in the sequences. index can be set to None if all indices of the sequence should be included in the plot

  • mapping (list) – List of 2 items specifying the mapping of the x and y components of the state space.

  • n_bins (int) – Size of the bins used to group the data

  • **kwargs (dict) – Additional arguments to be passed to pcolormesh function.

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.

class stonesoup.plotter.MetricPlotter[source]

Class for plotting Stone Soup metrics using matplotlib

A plotting class which is used to simplify the process of plotting metrics. Legends are automatically generated with each plot.

plot_metrics(metrics, generator_names=None, metric_names=None, combine_plots=True, **kwargs)[source]

Plots metrics

Plots each plottable metric passed in to metrics across a series of subplots and generates legend(s) automatically. Metrics are plotted as lines with default colors.

Users can change linestyle, color and marker or other features using keyword arguments. Any changes will apply to all metrics.

Parameters:
  • metrics (dict of Metric) – Dictionary of generated metrics to be plotted.

  • generator_names (list of str) – Generator(s) to extract specific metrics from metrics for plotting. Default None to take all metrics.

  • metric_names (list of str) – Specific metric(s) to extract from MetricGenerator for plotting. Default None to take all metrics in generators.

  • combine_plots (bool) – Plot metrics of same type on the same subplot. Default True.

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

Returns:

Figure containing subplots displaying all plottable metrics.

Return type:

matplotlib.pyplot.figure

static extract_metric_types(metrics)[source]

Identify the different types of metric held in dict of metrics.

Parameters:

metrics (dict of Metric) – Dictionary of metrics.

Returns:

Sorted list of types of metric

Return type:

list

combine_plots(metrics_to_plot, metrics_kwargs)[source]

Generates one subplot for each different metric type and plots metrics of the same type on same subplot. Metrics are plotted over time.

Parameters:
  • metrics_to_plot (dict of Metric) – Dictionary of metrics to plot.

  • metrics_kwargs (dict) – Keyword arguments to be passed to plot function.

Returns:

Figure containing subplots displaying metrics.

Return type:

matplotlib.pyplot.figure

plot_separately(metrics_to_plot, metrics_kwargs)[source]

Generates one subplot for each different individual metric and plots metric values over time.

Parameters:
  • metrics_to_plot (dict of Metric) – Dictionary of metrics to plot.

  • metrics_kwargs (dict) – Keyword arguments to be passed to plot function.

Returns:

Figure containing subplots displaying metrics.

Return type:

matplotlib.pyplot.figure

set_fig_title(title)[source]

Set title for the figure.

Parameters:

title (str) – Figure title text.

Return type:

Text instance of figure title.

set_ax_title(titles)[source]

Set axis titles for each axis in figure.

Parameters:

titles (list of str) – List of strings for title text for each axis.

Return type:

Text instance of axis titles.

class stonesoup.plotter.Plotterly(dimension=Dimension.TWO, axis_labels=None, **kwargs)[source]

Plotting class for building graphs of Stone Soup simulations using plotly

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 1D, 2D, or 3D plotting.

  • axis_labels (list) – Optional parameter to specify the axis labels for non-xy dimensions. Default None, i.e., “x” and “y”.

  • **kwargs (dict) – Additional arguments to be passed to the Plotly.graph_objects Figure.

fig

Generated figure to display graphs.

Type:

plotly.graph_objects.Figure

plot_ground_truths(truths, mapping, 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 line style, color and marker using keyword arguments. Any changes will apply to all ground truths.

Parameters:
  • truths (Collection of GroundTruthPath) – Collection of ground truths which will be plotted. If not a collection, 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.

  • label (str) – Label for truth data. Default is “Ground Truth”

  • **kwargs (dict) – Additional arguments to be passed to scatter function. Default is line=dict(dash="dash").

Deprecated since version 1.5: label has replaced truths_label. In the current implementation truths_label overrides label. However, use of truths_label may be removed in the future.

plot_measurements(measurements, mapping, measurement_model=None, label='Measurements', convert_measurements=True, **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 (Collection 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.

  • label (str) – Label for the measurements. Default is “Measurements”.

  • convert_measurements (bool) – Should the measurements be converted from measurement space to state space before being plotted. Default is True

  • **kwargs (dict) – Additional arguments to be passed to scatter function for detections. Defaults are marker=dict(color="#636EFA").

Deprecated since version 1.5: label has replaced measurements_label. In the current implementation measurements_label overrides label. However, use of measurements_label may be removed in the future.

get_next_color()[source]

Find the colour of the next plot. This approach to getting colour isn’t ideal, but should work in most cases… :returns: dist – Hex string for a colour :rtype: str

plot_tracks(tracks, mapping, uncertainty=False, particle=False, label='Tracks', ellipse_points=30, err_freq=1, same_color=False, **kwargs)[source]

Plots track(s)

Plots each track generated, generating a legend automatically. If uncertainty=True error ellipses are plotted. Tracks are plotted as solid lines with point markers and default colors.

Users can change line style, color and marker using keyword arguments.

Parameters:
  • tracks (Collection of Track) – Collection of tracks which will be plotted. If not a collection, 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.

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

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

  • ellipse_points (int) – Number of points for polygon approximating ellipse shape

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

  • same_color (bool) – Should all the tracks have the same colour. Default False

  • **kwargs (dict) – Additional arguments to be passed to scatter function. Defaults are marker=dict(symbol='square') for Update and marker=dict(symbol='circle') for other states.

Deprecated since version 1.5: label has replaced track_label. In the current implementation track_label overrides label. However, use of track_label may be removed in the future.

plot_sensors(sensors, mapping=[0, 1], label='Sensors', **kwargs)[source]

Plots sensor(s)

Plots sensors. Users can change the color and marker of sensors using keyword arguments. Default is a black ‘x’ marker.

Parameters:
  • sensors (Collection of Sensor) – Sensors to plot

  • mapping (list) – List of items specifying the mapping of the position components of the sensor’s position.

  • label (str) – Label to apply to all sensors for legend.

  • **kwargs (dict) – Additional arguments to be passed to scatter function for sensors. Defaults are marker=dict(symbol='x', color='black').

Deprecated since version 1.5: label has replaced sensor_label. In the current implementation sensor_label overrides label. However, use of sensor_label may be removed in the future.

hide_plot_traces(items_to_hide=None)[source]

Hide Plot Traces

This function allows plotting items to be invisible as default. Users can toggle the plot trace to visible.

Parameters:

items_to_hide (Iterable[str]) – The legend label (legendgroups) for the plot traces that should be invisible as default. If left as None no traces will be shown.

show_plot_traces(items_to_show=None)[source]

Show Plot Traces

This function allows specific plotting items to be shown as default. All labels not mentioned in items_to_show will be invisible and can be manually toggled on.

Parameters:

items_to_show (Iterable[str]) – The legend label (legendgroups) for the plot traces that should be shown as default. If left as None all traces will be shown.

class stonesoup.plotter.PolarPlotterly(dimension=Dimension.TWO, **kwargs)[source]
plot_state_sequence(state_sequences, angle_mapping: int, range_mapping: int = None, label='', **kwargs)[source]

Plots state sequence(s)

Plots each state sequence passed in to state_sequences and generates a legend automatically.

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

Parameters:
  • state_sequences (Collection of StateMutableSequence) – Collection of state sequences which will be plotted. If not a collection, and instead a single StateMutableSequence type, the argument is modified to be a set to allow for iteration.

  • angle_mapping (int) – Specifying the mapping of the angular component of the state space to be plotted.

  • range_mapping (int) – Specifying the mapping of the range component of the state space to be plotted. If None, the angular component will be plotted against time.

  • label (str) – Label for truth data.

  • **kwargs (dict) – Additional arguments to be passed to scatter function. Default is mode=marker. The default unit for the angular component is radians. This can be changed to degrees with the keyword argument thetaunit='degrees'.

plot_ground_truths(truths, mapping, 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 line style, color and marker using keyword arguments. Any changes will apply to all ground truths.

Parameters:
  • truths (Collection of GroundTruthPath) – Collection of ground truths which will be plotted. If not a collection, 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.

  • label (str) – Label for truth data. Default is “Ground Truth”.

  • **kwargs (dict) – Additional arguments to be passed to scatter function. Default is line=dict(dash="dash").

Deprecated since version 1.5: label has replaced truths_label. In the current implementation truths_label overrides label. However, use of truths_label may be removed in the future.

plot_measurements(measurements, mapping, measurement_model=None, label='Measurements', convert_measurements=True, **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 (Collection 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.

  • label (str) – Label for the measurements. Default is “Measurements”.

  • convert_measurements (bool) – Should the measurements be converted before being plotted. Default is True.

  • **kwargs (dict) – Additional arguments to be passed to scatter function for detections. Defaults are marker=dict(color="#636EFA").

Deprecated since version 1.5: label has replaced measurements_label. In the current implementation measurements_label overrides label. However, use of measurements_label may be removed in the future.

plot_tracks(tracks, mapping, uncertainty=False, particle=False, label='Tracks', **kwargs)[source]

Plots track(s)

Plots each track generated, generating a legend automatically. If uncertainty=True error ellipses are plotted. Tracks are plotted as solid lines with point markers and default colors.

Users can change line style, color and marker using keyword arguments.

Parameters:
  • tracks (Collection of Track) – Collection of tracks which will be plotted. If not a collection, 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.

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

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

  • **kwargs (dict) – Additional arguments to be passed to scatter function. Defaults are mode='markers+lines'.

Deprecated since version 1.5: label has replaced track_label. In the current implementation track_label overrides label. However, use of track_label may be removed in the future.

class stonesoup.plotter.AnimationPlotter(dimension=Dimension.TWO, x_label: str = '$x$', y_label: str = '$y$', title: str = None, legend_kwargs: dict = {}, **kwargs)[source]
run(times_to_plot: List[datetime] = None, plot_item_expiry: timedelta | None = None, **kwargs)[source]

Run the animation

Parameters:
  • times_to_plot (List of datetime) – List of datetime objects of when to refresh and draw the animation. Default None, where unique timestamps of data will be used.

  • plot_item_expiry (timedelta, Optional) – Describes how long states will remain present in the figure. Default value of None means data is shown indefinitely

  • **kwargs (dict) – Additional arguments to be passed to the animation.FuncAnimation function

save(filename='example.mp4', **kwargs)[source]

Save the animation

Parameters:
  • filename (str) – filename of animation file

  • **kwargs (dict) – Additional arguments to be passed to the animation.save function

plot_ground_truths(truths, mapping: List[int], label: str = '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 (Collection of GroundTruthPath) – Collection of ground truths which will be plotted. If not a collection 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.

  • label (str) – Label for truth data. Default is “Ground Truth”

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

Deprecated since version 1.5: label has replaced truths_label. In the current implementation truths_label overrides label. However, use of truths_label may be removed in the future.

plot_tracks(tracks, mapping: List[int], uncertainty=False, particle=False, label='Tracks', **kwargs)[source]

Plots track(s)

Plots each track generated, generating a legend automatically. Tracks are plotted as solid lines with point markers and default colors. Users can change linestyle, color and marker using keyword arguments.

Parameters:
  • tracks (Collection of Track) – Collection of tracks which will be plotted. If not a collection, 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) – Currently not implemented. If True, an error is raised

  • particle (bool) – Currently not implemented. If True, an error is raised

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

  • **kwargs (dict) – Additional arguments to be passed to plot function. Defaults are linestyle="-", marker='s' for Update and marker='o' for other states.

Deprecated since version 1.5: label has replaced track_label. In the current implementation track_label overrides label. However, use of track_label may be removed in the future.

plot_state_mutable_sequence(state_mutable_sequences, mapping: List[int], label: str, **plotting_kwargs)[source]

Plots State Mutable Sequence

Parameters:
  • state_mutable_sequences (Collection of StateMutableSequence) – Collection of states to be plotted

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

  • label (str) – 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 states.

plot_measurements(measurements, mapping, measurement_model=None, label='Measurements', convert_measurements=True, **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 (Collection 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.

  • label (str) – Label for measurements. Default is “Detections”.

  • convert_measurements (bool) – Should the measurements be converted from measurement space to state space before being plotted. Default is True

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

Deprecated since version 1.5: label has replaced measurements_label. In the current implementation measurements_label overrides label. However, use of measurements_label may be removed in the future.

classmethod run_animation(times_to_plot: List[datetime], data: Iterable[_AnimationPlotterDataClass], plot_item_expiry: timedelta | None = None, axis_padding: float = 0.1, figure_kwargs: dict = {}, animation_input_kwargs: dict = {}, legend_kwargs: dict = {}, x_label: str = '$x$', y_label: str = '$y$', plot_title: str = None) FuncAnimation[source]
Parameters:
  • times_to_plot (Iterable[datetime]) – All the times that the plotter should plot

  • data (Iterable[datetime]) – All the data that should be plotted

  • plot_item_expiry (timedelta) – How long a state should be displayed for. Default value of None means data is shown indefinitely

  • axis_padding (float) – How much extra space should be given around the edge of the plot

  • figure_kwargs (dict) – Keyword arguments for the pyplot figure function. See matplotlib.pyplot.figure for more details

  • animation_input_kwargs (dict) – Keyword arguments for FuncAnimation class. See matplotlib.animation.FuncAnimation for more details. Default values are: blit=False, repeat=False, interval=50

  • legend_kwargs (dict) – Keyword arguments for the pyplot legend function. See matplotlib.pyplot.legend for more details

  • x_label (str) – Label for the x axis

  • y_label (str) – Label for the y axis

  • plot_title (str) – Title for the plot

Returns:

Animation object

Return type:

animation.FuncAnimation

static update_animation(index: int, lines: List[Line2D], data_list: List[List[State]], start_times: List[datetime], end_times: List[datetime], title: str)[source]
Parameters:
  • index (int) – Which index of the start_times and end_times should be used

  • lines (List[Line2D]) – The data that will be plotted, to be plotted.

  • data_list (List[List[State]]) – All the data that should be plotted

  • start_times (List[datetime]) – lowest (earliest) time for an item to be plotted

  • end_times (List[datetime]) – highest (latest) time for an item to be plotted

  • title (str) – Title for the plot

Returns:

The data that will be plotted

Return type:

List[Line2D]

class stonesoup.plotter.AnimatedPlotterly(timesteps, tail_length=0.3, equal_size=False, sim_duration=6, **kwargs)[source]

Class for a 2D animated plotter that uses Plotly graph objects rather than matplotlib. This gives the user the ability to see how tracking works through time, while being able to interact with tracks, truths, etc, in the same way that is enabled by Plotly static plots.

Simplifies 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.

Parameters:
  • timesteps (Collection) – Collection of equally-spaced timesteps. Each animation frame is a timestep.

  • tail_length (float) – Percentage of sim time for which previous values will still be displayed for. Value can be between 0 and 1. Default is 0.3.

  • equal_size (bool) – Makes x and y axes equal when figure is resized. Default is False.

  • sim_duration (int) – Time taken to run animation (s). Default is 6

  • **kwargs – Additional arguments to be passed in the initialisation.

show()[source]

Display the animation.

plot_ground_truths(truths, mapping, label='Ground Truth', resize=True, **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 (Collection of GroundTruthPath) – Collection of ground truths which will be plotted. If not a collection 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.

  • label (str) – Name of ground truths in legend/plot

  • resize (bool) – if True, will resize figure to ensure that ground truths are in view

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

Deprecated since version 1.5: label has replaced truths_label. In the current implementation truths_label overrides label. However, use of truths_label may be removed in the future.

plot_measurements(measurements, mapping, measurement_model=None, resize=True, label='Measurements', convert_measurements=True, **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 (Collection 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.

  • resize (bool) – If True, will resize figure to ensure measurements are in view

  • label (str) – Label for the measurements. Default is “Measurements”.

  • convert_measurements (bool) – Should the measurements be converted from measurement space to state space before being plotted. Default is True

  • **kwargs (dict) – Additional arguments to be passed to scatter function for detections. Defaults are marker=dict(color="#636EFA").

Deprecated since version 1.5: label has replaced measurements_label. In the current implementation measurements_label overrides label. However, use of measurements_label may be removed in the future.

plot_tracks(tracks, mapping, uncertainty=False, resize=True, particle=False, plot_history=False, ellipse_points=30, label='Tracks', **kwargs)[source]

Plots each track generated, generating a legend automatically. If ‘uncertainty=True’, error ellipses are plotted. Tracks are plotted as solid lines with point markers and default colours.

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 (Collection of :class '~Track') – Collection of tracks which will be plotted. If not a collection, and instead a single :class:’~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

  • resize (bool) – If True, plotter will change bounds so that tracks are in view

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

  • plot_history (bool) – If true, plots all particles and uncertainty ellipses up to current time step

  • ellipse_points (int) – Number of points for polygon approximating ellipse shape

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

  • **kwargs (dict) – Additional arguments to be passed to plot function. Defaults are linestyle="-", marker='s' for Update and marker='o' for other states.

Deprecated since version 1.5: label has replaced track_label. In the current implementation track_label overrides label. However, use of track_label may be removed in the future.

plot_sensors(sensors, label='Sensors', resize=True, **kwargs)[source]

Plots sensor(s)

Plots sensors. Users can change the color and marker of detections using keyword arguments. Default is a black ‘x’ marker. Currently only works for stationary sensors.

Parameters:
  • sensors (Collection of Sensor) – Sensors to plot

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

  • **kwargs (dict) – Additional arguments to be passed to scatter function for detections. Defaults are marker=dict(symbol='x', color='black').

Deprecated since version 1.5: label has replaced sensor_label. In the current implementation sensor_label overrides label. However, use of sensor_label may be removed in the future.