diff --git a/Trajectories/Analysis/plot_traj.py b/Trajectories/Analysis/plot_traj.py index 1ac1cdadfb4f23d77c42236796e4366ee429895d..906685260f8066b2800a362047ea395df1b36198 100755 --- a/Trajectories/Analysis/plot_traj.py +++ b/Trajectories/Analysis/plot_traj.py @@ -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(