Skip to content

Commit

Permalink
Merge pull request #1078 from dstl/update_polar_example
Browse files Browse the repository at this point in the history
Improve polar plotting example
  • Loading branch information
sdhiscocks committed Sep 2, 2024
2 parents b24b5a2 + 0a161e3 commit 53ddb3b
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions docs/examples/plotting/Polar_Plotting.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
"""
Polar Plotting Example
========================
======================
This example demonstrates use of the :class:`~.PolarPlotterly` plotting class.
:class:`~.PolarPlotterly` uses :func:`plotly.graph_objects.Scatterpolar` to plot ground truths,
detections, and tracks in a polar plotter.
In this example, two airborne platforms are generated in a Cartesian state space. A
:class:`~.RadarBearingRange` sensor is used to convert the Cartesian state space to an
angular one. Angular ground truth is created using measurements without noise. Detections
(with noise) are also generated. Both detections and ground truth are plotted in a polar plot.
In this example, two platforms are generated in a Cartesian state space. A
:class:`~.RadarBearingRange` sensor is used to convert the Cartesian state space to an angular one.
Angular ground truth is created using measurements without noise. Detections (with noise) are also
generated. Both detections and ground truth are plotted in a polar plot.
"""

# %%
Expand Down Expand Up @@ -36,7 +36,7 @@
# -----------------------------------
# Two targets are created:
# #. Target 1 moves in a ‘C’ shape. First it moves west (negative x), then it starts a slow,
# long 180-degree turn moving south, until it is moving east (positive x).
# long 180-degree turn anti-clockwise, until it is moving east (positive x).
# #. Target 2 moves in a straight line from north to south.

# Create manoeuvre behaviours and durations for our moving platform
Expand Down Expand Up @@ -91,9 +91,9 @@

# %%
# Generate Angular State Space Data
# ----------------------------------
# Measure the previously generated cartesian state space using a
# :class:`~.RadarBearingRange` sensor:
# ---------------------------------
# Angular state space data is generated by measuring the previously generated Cartesian state
# space with a :class:`~.RadarBearingRange` sensor:

# %%
# Create sensor:
Expand Down Expand Up @@ -121,13 +121,13 @@
detections.extend(sensor.measure({target_1[t], target_2[t]}, noise=True))

# %%
# Time (s) vs Azimuth Angle (Radians)
# Azimuth Angle (Radians) vs Time (s)
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
mapping = [0]
plotter_az_t_cart = Plotterly(dimension=1,
title="Cartesian - Time (s) vs Azimuth Angle (Radians)",
title="Cartesian - Azimuth Angle (Radians) vs Time (s)",
xaxis=dict(title=dict(text="Time (seconds)")),
yaxis=dict(title=dict(text="Bearing (Radians)"))
yaxis=dict(title=dict(text="Azimuth Angle (Radians)"))
)
plotter_az_t_cart.plot_ground_truths({angular_ground_truth_1},
mapping=mapping, label="Target 1")
Expand All @@ -147,13 +147,13 @@
# Create Polar Plots
# ------------------
# :class:`~.PolarPlotterly` inherits from :class:`~._Plotter` and therefore has all the same
# methods are the other plotters.
# methods as the other plotters.

# %%
# Azimuth Angle (Degrees) vs Time (s)
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
mapping = [0]
plotter_az_t = PolarPlotterly(title="Azimuth Angle (Degrees) vs Time (s)")
plotter_az_t = PolarPlotterly(title="Polar - Azimuth Angle (Degrees) vs Time (s)")
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)
Expand Down Expand Up @@ -187,9 +187,9 @@


# %%
# Reference XY Plot
# ^^^^^^^^^^^^^^^^^
# This is similar to the previous x/y plot but also contains the detections.
# Reference Cartesian Plot
# ^^^^^^^^^^^^^^^^^^^^^^^^
# For comparison, this is the original Cartesian plot with the detections displayed
plotter_xy.plot_measurements(detections, mapping=[0, 2])
plotter_xy.fig

Expand Down

0 comments on commit 53ddb3b

Please sign in to comment.