Skip to content
Snippets Groups Projects
Commit ae0afc8e authored by Lionel GUEZ's avatar Lionel GUEZ
Browse files

Add argument `arrows`

To function `plot_single_traj`.
parent da2dd9e2
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,7 @@ and markers for the extrema at initial positions.
import random
import numpy as np
from matplotlib import patches
import util_eddies
......@@ -42,17 +43,46 @@ def plot_single_traj(
annotate_flag,
color,
color_initial,
arrows,
):
x, y = get_extr_coord(traj, e_overestim, SHPC, orientation)
ax.plot(x, y, color, linewidth=0.5, transform=src_crs)
ax.plot(
x[0],
y[0],
marker="s",
markersize=2,
color=color_initial,
transform=src_crs,
)
if arrows:
# Markers at eatch point and arrows between points, all in the
# same color
ax.plot(
x,
y,
marker="o",
linestyle="",
markersize=2,
color=color,
transform=src_crs,
)
# We do not use quiver because it does not work easily with a
# projection and angles="xy", scale_units="xy", scale=1.
for i in range(len(x) - 1):
# Do not use argument transform of FancyArrowPatch because
# it does not work with ccrs.Geodetic().
posA = ax.projection.transform_point(x[i], y[i], src_crs)
posB = ax.projection.transform_point(x[i + 1], y[i + 1], src_crs)
arrow = patches.FancyArrowPatch(
posA, posB, arrowstyle="-|>", color=color, mutation_scale=10
)
ax.add_patch(arrow)
else:
# Marker at the initial point only, with a different color, no arrows
ax.plot(x, y, color, linewidth=0.5, transform=src_crs)
ax.plot(
x[0],
y[0],
marker="s",
markersize=2,
color=color_initial,
transform=src_crs,
)
if annotate_flag:
ax.annotate(
......@@ -150,6 +180,7 @@ if __name__ == "__main__":
args.annotate,
color="red",
color_initial="green",
arrows=False,
)
break
else:
......@@ -165,6 +196,7 @@ if __name__ == "__main__":
args.annotate,
color="red",
color_initial="green",
arrows=False,
)
else:
if args.alt:
......@@ -202,6 +234,7 @@ if __name__ == "__main__":
args.annotate,
color,
color_initial,
arrows=False,
)
else:
# args.min_duration > 1
......@@ -227,6 +260,7 @@ if __name__ == "__main__":
args.annotate,
color,
color_initial,
arrows=False,
)
print(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment