Skip to content

Commit

Permalink
Fixes to plotting/legends in AnimatedPlotterly
Browse files Browse the repository at this point in the history
Includes fix introduce in #990 with clutter plotting, and incorrectly
grouping legend items
  • Loading branch information
sdhiscocks committed Apr 26, 2024
1 parent 40e8085 commit d679cbd
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions stonesoup/plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2610,7 +2610,7 @@ def plot_measurements(self, measurements, mapping, measurement_model=None,
name = measurements_label + "<br>(Detections)"
measurement_kwargs = dict(x=[], y=[], mode='markers',
name=name,
legendgroup='Detections (Measurements)',
legendgroup=name,
legendrank=200, showlegend=True,
marker=dict(color="#636EFA"), hoverinfo='none')
merge(measurement_kwargs, kwargs)
Expand All @@ -2622,9 +2622,12 @@ def plot_measurements(self, measurements, mapping, measurement_model=None,

# change necessary kwargs to initialise clutter trace
name = measurements_label + "<br>(Clutter)"
clutter_kwargs = {"legendgroup": 'Clutter', "legendrank": 300,
"marker": dict(symbol="star-triangle-up", color='#FECB52'),
"name": name, 'showlegend': True}
clutter_kwargs = dict(x=[], y=[], mode='markers',
name=name,
legendgroup=name,
legendrank=300, showlegend=True,
marker=dict(symbol="star-triangle-up", color='#FECB52'),
hoverinfo='none')
merge(clutter_kwargs, kwargs)

self.fig.add_trace(go.Scatter(clutter_kwargs)) # trace for plotting clutter
Expand Down Expand Up @@ -2823,10 +2826,10 @@ def plot_tracks(self, tracks, mapping, uncertainty=False, resize=True,
self._resize(data, "tracks")

if uncertainty: # plot ellipses

uncertainty_kwargs = dict(x=[], y=[], legendgroup='Uncertainty', fill='toself',
name = f'{track_label}<br>Uncertainty'
uncertainty_kwargs = dict(x=[], y=[], legendgroup=name, fill='toself',
fillcolor=self.colorway[2],
opacity=0.2, legendrank=500, name='Track<br>Uncertainty',
opacity=0.2, legendrank=500, name=name,
hoverinfo='skip',
mode='none', showlegend=True)
uncertainty_kwargs.update(kwargs)
Expand All @@ -2848,10 +2851,10 @@ def plot_tracks(self, tracks, mapping, uncertainty=False, resize=True,
if particle: # plot particles

# initialise traces. One for legend and one per track

name = f'{track_label}<br>Particles'
particle_kwargs = dict(mode='markers', marker=dict(size=2, color=self.colorway[2]),
opacity=0.4,
hoverinfo='skip', legendgroup='particles', name='particles',
hoverinfo='skip', legendgroup=name, name=name,
legendrank=520, showlegend=True)
# apply any keyword arguments
particle_kwargs.update(kwargs)
Expand Down

0 comments on commit d679cbd

Please sign in to comment.