Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Plotter Labels #1071

Merged
merged 7 commits into from
Sep 2, 2024
6 changes: 3 additions & 3 deletions docs/examples/dataassociation/Comparing_EHM_JPDA_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,11 +383,11 @@
plotter.plot_ground_truths(groundtruths, [0, 2])
plotter.plot_measurements(detections_set, [0, 2])
plotter.plot_tracks(JPDA_tracks, [0, 2], line= dict(color='orange'),
track_label='JPDA tracks')
label='JPDA tracks')
plotter.plot_tracks(EHM1_tracks, [0, 2], line= dict(color='green', dash='dot'),
track_label='EHM1 tracks')
label='EHM1 tracks')
plotter.plot_tracks(EHM2_tracks, [0, 2], line= dict(color='red', dash='dot'),
track_label='EHM2 tracks')
label='EHM2 tracks')
plotter.fig

# %%
Expand Down
22 changes: 11 additions & 11 deletions docs/examples/dataassociation/One_to_One_Associator.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@

plotter = Plotterly()
plotter.plot_tracks(tracks=[Track(state) for state in states_from_a],
mapping=[0, 1], track_label="Source A",
mapping=[0, 1], label="Source A",
mode="markers", marker=dict(symbol="cross", color=next(colours_iter)))

plotter.plot_tracks(tracks=[Track(state) for state in states_from_b],
mapping=[0, 1], track_label="Source B",
mapping=[0, 1], label="Source B",
mode="markers", marker=dict(symbol="circle", color=next(colours_iter)))

plotter.fig
Expand Down Expand Up @@ -109,17 +109,17 @@
track = Track(state_from_a, init_metadata=dict(source="a", association=idx))
plotter.plot_tracks(track,
mapping=[0, 1], mode="markers",
track_label=f"{state_names[state_from_a]}, Association {idx}",
label=f"{state_names[state_from_a]}, Association {idx}",
marker=dict(symbol="cross", color=colour))

track = Track(state_from_b, init_metadata=dict(source="b", association=idx))
plotter.plot_tracks(track, mapping=[0, 1], mode="markers",
track_label=f"{state_names[state_from_b]}, Association {idx}",
label=f"{state_names[state_from_b]}, Association {idx}",
marker=dict(symbol="circle", color=colour))

track = Track([state_from_a, state_from_b], init_metadata=dict(association=idx))
plotter.plot_tracks(track, mapping=[0, 1], mode="lines",
track_label=f"Association {idx}",
label=f"Association {idx}",
line=dict(color=colour))

dist_between_states = Euclidean()(state_from_a, state_from_b)
Expand All @@ -134,7 +134,7 @@
colour = next(colours_iter)
track = Track(state, init_metadata=dict(source="a", association=None))
plotter.plot_tracks(track, mapping=[0, 1],
track_label=f"{state_names[state]}, No Association",
label=f"{state_names[state]}, No Association",
mode="markers", marker=dict(symbol="cross", color=colour))

for state in unassociated_states_b:
Expand All @@ -143,7 +143,7 @@
colour = next(colours_iter)
track = Track(state, init_metadata=dict(source="b", association=None))
plotter.plot_tracks(track, mapping=[0, 1],
track_label=f"{state_names[state]}, No Association",
label=f"{state_names[state]}, No Association",
mode="markers", marker=dict(symbol="circle", color=colour))

# %%
Expand Down Expand Up @@ -215,11 +215,11 @@

colour = next(colours_iter)
for track in tracks_a:
plotter.plot_tracks(track, mapping=[0, 1], track_label=track.id, marker=dict(color=colour))
plotter.plot_tracks(track, mapping=[0, 1], label=track.id, marker=dict(color=colour))

colour = next(colours_iter)
for track in tracks_b:
plotter.plot_tracks(track, mapping=[0, 1], track_label=track.id, marker=dict(color=colour))
plotter.plot_tracks(track, mapping=[0, 1], label=track.id, marker=dict(color=colour))

plotter.fig

Expand Down Expand Up @@ -272,15 +272,15 @@
print('Associated together', [track.id for track in assoc.objects])
colour = next(colours_iter)
for track in assoc.objects:
plotter.plot_tracks(track, mapping=[0, 1], track_label=track.id,
plotter.plot_tracks(track, mapping=[0, 1], label=track.id,
marker=dict(color=colour))

print("Not Associated in A: ", [track.id for track in unassociated_a])
print("Not Associated in B: ", [track.id for track in unassociated_b])

for track in [*unassociated_a, *unassociated_b]:
colour = next(colours_iter)
plotter.plot_tracks(track, mapping=[0, 1], track_label=track.id, marker=dict(color=colour))
plotter.plot_tracks(track, mapping=[0, 1], label=track.id, marker=dict(color=colour))

plotter.fig

Expand Down
2 changes: 1 addition & 1 deletion docs/examples/dataassociation/mht_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@

tracks.add(track)

plotter.plot_tracks(tracks, [0, 2], track_label="Tracks", line=dict(color="Green"))
plotter.plot_tracks(tracks, [0, 2], label="Tracks", line=dict(color="Green"))
plotter.fig

# %%
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/eot/extended_object_tracking_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@
tracks.update(current_tracks)

plotter.plot_measurements(centroid_detections, [0, 2], marker=dict(color='red'),
measurements_label='Cluster centroids')
label='Cluster centroids')
plotter.plot_tracks(tracks, [0, 2])
plotter.fig

Expand Down
8 changes: 4 additions & 4 deletions docs/examples/filters/Multi_Tracker_Example.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,13 +365,13 @@

# %%
# Finally, we plot the results:
plotter.plot_tracks(tracks_EKF, [0, 2], track_label="EKF", line=dict(color="orange"),
plotter.plot_tracks(tracks_EKF, [0, 2], label="EKF", line=dict(color="orange"),
uncertainty=False)
plotter.plot_tracks(tracks_UKF, [0, 2], track_label="UKF", line=dict(color="blue"),
plotter.plot_tracks(tracks_UKF, [0, 2], label="UKF", line=dict(color="blue"),
uncertainty=False)
plotter.plot_tracks(tracks_PF, [0, 2], track_label="PF", line=dict(color="brown"),
plotter.plot_tracks(tracks_PF, [0, 2], label="PF", line=dict(color="brown"),
uncertainty=False)
plotter.plot_tracks(tracks_ESIF, [0, 2], track_label="ESIF", line=dict(color="green"),
plotter.plot_tracks(tracks_ESIF, [0, 2], label="ESIF", line=dict(color="green"),
uncertainty=False)
plotter.fig

Expand Down
2 changes: 1 addition & 1 deletion docs/examples/filters/bearing_only_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@
plotter = AnimationPlotter(legend_kwargs=dict(loc='upper left'))
plotter.plot_ground_truths(groundtruth_paths, (0,2))
plotter.plot_tracks(kalman_tracks, (0,2))
plotter.plot_ground_truths(platform, (0,2), truths_label="Sensor Platform")
plotter.plot_ground_truths(platform, (0,2), label="Sensor Platform")
plotter.run()

# %%
Expand Down
12 changes: 6 additions & 6 deletions docs/examples/oosm/KalmanFilterOOSMExample.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,12 @@
plotter = AnimatedPlotterly(timesteps=time_steps)
plotter.plot_ground_truths(truth, [0, 2])
plotter.plot_measurements(measurements1, [0, 2], marker=dict(color='blue'),
measurements_label='Detections with no lag')
label='Detections with no lag')
plotter.plot_measurements(measurements2, [0, 2], marker=dict(color='orange'),
measurements_label='Detections with lag')
label='Detections with lag')
plotter.plot_sensors([sensor1_platform, sensor2_platform],
marker=dict(color='black', symbol='129', size=15),
sensor_label='Fixed Platforms')
label='Fixed Platforms')
plotter.fig

# %%
Expand Down Expand Up @@ -297,10 +297,10 @@
# However, it is interesting to see a 1-to-1 comparison between the three trackers, even if the
# Tracker 2 track is not, visually, lagging behind.

plotter.plot_tracks(track1, [0, 2], track_label='Tracker 1')
plotter.plot_tracks(track2, [0, 2], track_label='Tracker 2',
plotter.plot_tracks(track1, [0, 2], label='Tracker 1')
plotter.plot_tracks(track2, [0, 2], label='Tracker 2',
line=dict(color='red'))
plotter.plot_tracks(track3, [0, 2], track_label='Tracker 3',
plotter.plot_tracks(track3, [0, 2], label='Tracker 3',
line=dict(color='green'))
plotter.fig

Expand Down
4 changes: 2 additions & 2 deletions docs/examples/oosm/PF_OOSM_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,9 @@
plotter.plot_ground_truths(truths, [0, 2])

plotter.plot_measurements(scans_detections, [0, 2])
plotter.plot_tracks(track, [0, 2], track_label='Track dealing with OOSM',
plotter.plot_tracks(track, [0, 2], label='Track dealing with OOSM',
line=dict(color='blue'))
plotter.plot_tracks(track2, [0, 2], track_label='Track ignoring OOSM')
plotter.plot_tracks(track2, [0, 2], label='Track ignoring OOSM')
plotter.fig

# %%
Expand Down
8 changes: 4 additions & 4 deletions docs/examples/oosm/example_oosm_algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,11 +339,11 @@
from stonesoup.plotter import AnimatedPlotterly
plotter = AnimatedPlotterly(timesteps=timestamps)
plotter.plot_ground_truths(truths, [0, 2])
plotter.plot_measurements(scan_s1, [0, 2], measurements_label='scan1', measurement_model=sensor_1_mm)
plotter.plot_measurements(scan_s2, [0, 2], measurements_label='scan2', measurement_model=sensor_1_mm)
plotter.plot_tracks(oosm_tracks, [0, 2], track_label='OOSM Tracks',
plotter.plot_measurements(scan_s1, [0, 2], label='scan1', measurement_model=sensor_1_mm)
plotter.plot_measurements(scan_s2, [0, 2], label='scan2', measurement_model=sensor_1_mm)
plotter.plot_tracks(oosm_tracks, [0, 2], label='OOSM Tracks',
line= dict(color='orange'))
plotter.plot_tracks(noOsm_tracks, [0, 2], track_label='no-OOSM Tracks',
plotter.plot_tracks(noOsm_tracks, [0, 2], label='no-OOSM Tracks',
line= dict(color='red'))
plotter.fig

Expand Down
6 changes: 3 additions & 3 deletions docs/examples/oosm/example_simple_oosm.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,9 @@

plotter = AnimatedPlotterly(timesteps=timestamps)
plotter.plot_ground_truths(truths, [0, 2])
plotter.plot_measurements(scans_detections, [0, 2], measurements_label='Detections',
plotter.plot_measurements(scans_detections, [0, 2], label='Detections',
measurement_model=measurement_model)
plotter.plot_tracks(track_lag, [0, 2], line= dict(color='grey'), track_label='Track with lag')
plotter.plot_tracks(track_lag, [0, 2], line= dict(color='grey'), label='Track with lag')
plotter.fig

# %%
Expand Down Expand Up @@ -262,7 +262,7 @@
# Plotting the final track
# ------------------------

plotter.plot_tracks(track, [0, 2], line= dict(color='blue'), track_label='Track with OOSM treated')
plotter.plot_tracks(track, [0, 2], line= dict(color='blue'), label='Track with OOSM treated')
plotter.fig

# %%
Expand Down
16 changes: 8 additions & 8 deletions docs/examples/plotting/Polar_Plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@
# :class:`~.Plotterly` plotting class:
plotter_xy = Plotterly(title="Bird's Eye View of Targets")
mapping = [0, 2]
plotter_xy.plot_ground_truths(target_1, mapping=[0, 2], truths_label="Target 1")
plotter_xy.plot_ground_truths(target_2, mapping=[0, 2], truths_label="Target 2")
plotter_xy.plot_ground_truths(target_1, mapping=[0, 2], label="Target 1")
plotter_xy.plot_ground_truths(target_2, mapping=[0, 2], label="Target 2")
plotter_xy.fig

# %%
Expand Down Expand Up @@ -130,9 +130,9 @@
yaxis=dict(title=dict(text="Bearing (Radians)"))
)
plotter_az_t_cart.plot_ground_truths({angular_ground_truth_1},
mapping=mapping, truths_label="Target 1")
mapping=mapping, label="Target 1")
plotter_az_t_cart.plot_ground_truths({angular_ground_truth_2},
mapping=mapping, truths_label="Target 2")
mapping=mapping, label="Target 2")
plotter_az_t_cart.plot_measurements(detections, mapping=mapping, convert_measurements=False)
plotter_az_t_cart.fig

Expand All @@ -154,8 +154,8 @@
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
mapping = [0]
plotter_az_t = PolarPlotterly(title="Azimuth Angle (Degrees) vs Time (s)")
plotter_az_t.plot_ground_truths({angular_ground_truth_1}, mapping=mapping, truths_label="Target 1")
plotter_az_t.plot_ground_truths({angular_ground_truth_2}, mapping=mapping, truths_label="Target 2")
plotter_az_t.plot_ground_truths({angular_ground_truth_1}, mapping=mapping, label="Target 1")
plotter_az_t.plot_ground_truths({angular_ground_truth_2}, mapping=mapping, label="Target 2")
plotter_az_t.plot_measurements(detections, mapping=mapping, convert_measurements=False)
plotter_az_t.fig

Expand All @@ -175,8 +175,8 @@
# sphinx_gallery_thumbnail_number = 4
plotter_az_r = PolarPlotterly(title="Azimuth Angle (Degrees) vs Range (m)")
mapping = [0, 1]
plotter_az_r.plot_ground_truths({angular_ground_truth_1}, mapping=mapping, truths_label="Target 1")
plotter_az_r.plot_ground_truths({angular_ground_truth_2}, mapping=mapping, truths_label="Target 2")
plotter_az_r.plot_ground_truths({angular_ground_truth_1}, mapping=mapping, label="Target 1")
plotter_az_r.plot_ground_truths({angular_ground_truth_2}, mapping=mapping, label="Target 2")
plotter_az_r.plot_measurements(detections, mapping=mapping, convert_measurements=False)
plotter_az_r.fig

Expand Down
14 changes: 7 additions & 7 deletions docs/examples/sensorfusion/Example_data_fusion_from_sensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,19 +459,19 @@

plotter = Plotterly()
plotter.plot_measurements(s1_detections, [0, 2],
measurements_label='Radar 1 measurements'),
label='Radar 1 measurements'),
plotter.plot_measurements(s2_detections, [0, 2],
measurements_label='Radar 2 measurements')
plotter.plot_tracks(ukf_tracks, [0, 2], line=dict(color='green'), track_label='UKF tracks')
plotter.plot_tracks(ekf_tracks, [0, 2], line=dict(color='blue'), track_label='EKF tracks')
label='Radar 2 measurements')
plotter.plot_tracks(ukf_tracks, [0, 2], line=dict(color='green'), label='UKF tracks')
plotter.plot_tracks(ekf_tracks, [0, 2], line=dict(color='blue'), label='EKF tracks')
plotter.plot_tracks(pf_tracks, [0, 2], particle=False, line=dict(color='red'),
track_label='PF tracks')
label='PF tracks')
plotter.plot_ground_truths(truths, [0, 2])
plotter.plot_sensors(sensor1_platform, [0, 1], marker=dict(color='black', symbol='129', size=15),
sensor_label='Fixed Platform')
label='Fixed Platform')
plotter.plot_ground_truths(sensor2_platform, [0, 2], marker=dict(color='orange', symbol='cross',
size=25),
truths_label='Moving Platform')
label='Moving Platform')
plotter.fig

# %%
Expand Down
12 changes: 6 additions & 6 deletions docs/examples/trackfusion/Track2Track_Fusion_Example.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,17 +629,17 @@
plotter.plot_ground_truths(truths, [0, 2],
color='black')
plotter.plot_measurements(s1_detections, [0, 2], color='orange', marker='*',
measurements_label='Measurements - Airborne Radar')
label='Measurements - Airborne Radar')
plotter.plot_measurements(s2_detections, [0, 2], color='blue', marker='*',
measurements_label='Measurements - Ground Radar')
label='Measurements - Ground Radar')
plotter.plot_tracks(jpda_tracks, [0, 2], color='red',
track_label='Tracks - Airborne Radar (JPDAF)')
label='Tracks - Airborne Radar (JPDAF)')
plotter.plot_tracks(gmlcc_tracks, [0, 2], color='purple',
track_label='Tracks - Ground Radar (GM-LCC)')
label='Tracks - Ground Radar (GM-LCC)')
plotter.plot_tracks(meas_fusion_tracks, [0, 2], color='green',
track_label='Tracks - Measurement Fusion (GM-PHD)')
label='Tracks - Measurement Fusion (GM-PHD)')
plotter.plot_tracks(track_fusion_tracks, [0, 2], color='pink',
track_label='Tracks - Covariance Intersection (GM-PHD)')
label='Tracks - Covariance Intersection (GM-PHD)')

# Format the legend a bit. Set the position outside of the plot, and
# swap the order of the clutter and ground radar measurements
Expand Down
16 changes: 8 additions & 8 deletions docs/examples/trackfusion/track_fusion_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,9 @@
# Plot the detections from the two radars
plotter = Plotterly()
plotter.plot_measurements(s1_detections, [0, 2], marker=dict(color='red'),
measurements_label='Sensor 1 measurements')
label='Sensor 1 measurements')
plotter.plot_measurements(s2_detections, [0, 2], marker=dict(color='blue'),
measurements_label='Sensor 2 measurements')
label='Sensor 2 measurements')
plotter.plot_sensors({sensor1_platform, sensor2_platform}, [0, 1],
marker=dict(color='black', symbol='1', size=10))
plotter.plot_ground_truths(truths, [0, 2])
Expand Down Expand Up @@ -431,12 +431,12 @@
# Let's visualise the various tracks and detections in the cases
# using the Kalman and particle filters.

plotter.plot_tracks(PF_track1, [0, 2], line=dict(color="orange"), track_label='PF partial track 1')
plotter.plot_tracks(PF_track2, [0, 2], line=dict(color="gold"), track_label='PF partial track 2')
plotter.plot_tracks(PF_fused_track, [0, 2], line=dict(color="red"), track_label='PF fused track')
plotter.plot_tracks(KF_fused_track, [0, 2], line=dict(color="blue"), track_label='KF fused track')
plotter.plot_tracks(KF_track1, [0, 2], line=dict(color="cyan"), track_label='KF partial track 1')
plotter.plot_tracks(KF_track2, [0, 2], line=dict(color="skyblue"), track_label='KF partial track 2')
plotter.plot_tracks(PF_track1, [0, 2], line=dict(color="orange"), label='PF partial track 1')
plotter.plot_tracks(PF_track2, [0, 2], line=dict(color="gold"), label='PF partial track 2')
plotter.plot_tracks(PF_fused_track, [0, 2], line=dict(color="red"), label='PF fused track')
plotter.plot_tracks(KF_fused_track, [0, 2], line=dict(color="blue"), label='KF fused track')
plotter.plot_tracks(KF_track1, [0, 2], line=dict(color="cyan"), label='KF partial track 1')
plotter.plot_tracks(KF_track2, [0, 2], line=dict(color="skyblue"), label='KF partial track 2')

plotter.fig

Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/filters/AKKF.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@

plotter = Plotter()
plotter.plot_ground_truths(truth, [0, 2], linewidth=3.0, color='black')
plotter.plot_tracks(track, [0, 2], track_label='AKKF - quadratic', color='royalblue')
plotter.plot_tracks(track, [0, 2], label='AKKF - quadratic', color='royalblue')
plotter.fig

# %%
Expand Down
4 changes: 2 additions & 2 deletions docs/tutorials/filters/ASDFilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,9 @@
asd_states = sorted(asd_states, key=attrgetter('timestamp'))

plotter.plot_tracks({track2}, [0, 2], uncertainty=True, line=dict(color='green'),
track_label="Equivalent track without ASD")
label="Equivalent track without ASD")
plotter.plot_tracks({Track(asd_states)}, [0, 2], line=dict(color='red'),
track_label="ASD Track")
label="ASD Track")
plotter.fig

# %%
Expand Down
Loading