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

Bug fix: adapt the central longitude

Adapt the central longitude of the projection, depending on window or
position of chosen node. Else we can have arrows crossing the whole projection.
parent 0bb53b24
No related branches found
No related tags found
No related merge requests found
......@@ -58,7 +58,7 @@ def plot_nbunch(G, nbunch, color = '#1f78b4', label = None, ax = None):
if label is not None:
for n in nbunch:
if is_node_type(G, n, label):
xy = ccrs.PlateCarree().transform_point(*pos[n], src_crs)
xy = ax.projection.transform_point(*pos[n], src_crs)
ax.annotate(str(n), xy, color = color, xytext = (2, 2),
textcoords = 'offset points')
......@@ -106,7 +106,6 @@ if __name__ == "__main__":
print("Reading edgelist.csv in current directory...")
G = report_graph.read_eddy_graph("edgelist.csv", args.shp_tr_dir)
plt.figure()
ax = plt.axes(projection=ccrs.PlateCarree())
if args.window is not None:
if args.window[2] - args.window[0] > 360:
......@@ -116,13 +115,18 @@ if __name__ == "__main__":
if plot_eddy_contours.in_window(d["coordinates"], args.window):
if "component" not in d: report_graph.add_component(G, n)
dest_crs = ccrs.PlateCarree((args.window[0] + args.window[2]) / 2)
ax = plt.axes(projection = dest_crs)
plot_all_components(G, args.label)
elif args.node is not None:
source = tuple(args.node)
report_graph.add_component(G, source)
dest_crs = ccrs.PlateCarree(G.nodes[source]["coordinates"][0])
ax = plt.axes(projection = dest_crs)
plot_nbunch(G, G.nodes[source]["component"], label = args.label)
else:
assign_all_components(G)
ax = plt.axes(projection = ccrs.PlateCarree())
plot_all_components(G, args.label)
ax.coastlines()
......
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