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().
- 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.
**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
- ax
Generated axes for graphs to be plotted on
- Type
- legend_dict
Dictionary of legend handles as
matplotlib.legend_handler.HandlerBase
and labels as str- Type
- 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 (Collection of
GroundTruthPath
) – Collection of ground truths which will be plotted. If not a collection and instead a singleGroundTruthPath
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 (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.**kwargs (dict) – Additional arguments to be passed to plot function for detections. Defaults are
marker='o'
andcolor='b'
.
- plot_tracks(tracks, mapping, uncertainty=False, particle=False, track_label='Tracks', 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 ellipses are plotted. If being plotted in 3D, uncertainty bars are plotted everyerr_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 singleTrack
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='s'
forUpdate
andmarker='o'
for other states.
- plot_sensors(sensors, sensor_label='Sensors', **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.
- 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: Iterable[StateMutableSequence], index: Optional[int] = -1, mapping=(0, 2), n_bins=300, **kwargs)[source]
- Parameters
state_sequences (an iterable of
StateMutableSequence
) – Set of tracks which will be plotted. If not a set, and instead a singleTrack
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.Plotterly(dimension=Dimension.TWO, **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 2D or 3D plotting. Currently only 2D plotting is supported.
**kwargs (dict) – Additional arguments to be passed to Figure.
- fig
Generated figure for graphs to be plotted on
- Type
plotly.graph_objects.Figure
- 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 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 singleGroundTruthPath
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 scatter function. Default is
line=dict(dash="dash")
.
- 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 (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.measurements_label (str) – Label for the measurements. Default is “Measurements”.
**kwargs (dict) – Additional arguments to be passed to scatter function for detections. Defaults are
marker=dict(color="#636EFA")
.
- plot_tracks(tracks, mapping, uncertainty=False, particle=False, track_label='Tracks', ellipse_points=30, **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 singleTrack
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.
track_label (str) – Label to apply to all tracks for legend.
ellipse_points (int) – Number of points for polygon approximating ellipse shape
**kwargs (dict) – Additional arguments to be passed to scatter function. Defaults are
marker=dict(symbol='square')
forUpdate
andmarker=dict(symbol='circle')
for other states.