Skip to content

Commit

Permalink
Support showing edges
Browse files Browse the repository at this point in the history
  • Loading branch information
xylar committed Oct 27, 2023
1 parent da32a1f commit 0679279
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion polaris/viz/spherical.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def plot_global_mpas_field(mesh_filename, da, out_filename, config,
colormap_section, title=None,
plot_land=True, colorbar_label='',
central_longitude=0., figsize=(8, 4.5),
dpi=200):
dpi=200, patch_edge_color=None):
"""
Plots a data set as a longitude-latitude map
Expand Down Expand Up @@ -66,6 +66,9 @@ def plot_global_mpas_field(mesh_filename, da, out_filename, config,
dpi : int, optional
Dots per inch for the output plot
patch_edge_color : str, optional
The color of patch edges (if not the same as the face)
"""
matplotlib.use('agg')
uxgrid = ux.open_grid(mesh_filename)
Expand Down Expand Up @@ -104,6 +107,13 @@ def plot_global_mpas_field(mesh_filename, da, out_filename, config,

plot.opts(cbar_extend='both', cbar_width=0.03)

if patch_edge_color is not None:
gdf_grid = uxgrid.to_geodataframe()
# color parameter seems to be ignored -- always plots blue
edge_plot = gdf_grid.hvplot.paths(
linewidth=0.2, color=patch_edge_color, projection=projection)
plot = plot * edge_plot

fig = hv.render(plot)
fig.set_size_inches(figsize)
fig.savefig(out_filename, dpi=dpi, bbox_inches='tight', pad_inches=0.1)
Expand Down

0 comments on commit 0679279

Please sign in to comment.