Skip to content

Commit

Permalink
Update misfit lune plot to account for deviatoric grids. Addresses is…
Browse files Browse the repository at this point in the history
…sue #273

Added a conditional statement for the 'contour' plot mode. If the contour plot fails, it now produces an equivalent 'colormesh' plot.
  • Loading branch information
thurinj committed Nov 27, 2024
1 parent 959d5d6 commit 76d54bf
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions mtuq/graphics/uq/_matplotlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,17 @@ def _plot_lune_matplotlib(filename, longitude, latitude, values,
vmin, vmax = np.nanpercentile(np.asarray(values), clip_interval)
im = ax.pcolormesh(x, y, values, cmap=colormap, vmin=vmin, vmax=vmax, shading='nearest', zorder=10)
elif plot_type == 'contour':
# Plot using contourf
levels = 20
im = ax.contourf(x, y, values, cmap=colormap, levels=levels, zorder=10)
im = None
try:
im = ax.contourf(x, y, values, cmap=colormap, levels=20, zorder=10)
except Exception:
print('Not enough data to plot contour, switching to colormesh...')
im = ax.pcolormesh(
x, y, values, cmap=colormap,
vmin=np.nanpercentile(values, clip_interval[0]),
vmax=np.nanpercentile(values, clip_interval[1]),
shading='nearest', zorder=10
)
elif plot_type == 'scatter':
# Prepare colormap
boundaries = np.linspace(0, 5, 6)
Expand Down

0 comments on commit 76d54bf

Please sign in to comment.