Skip to content

Commit

Permalink
Merge pull request clawpack#297 from kbarnhart/add_imshow_norm
Browse files Browse the repository at this point in the history
Add ability to pass norm and alpha values to imshow
rjleveque authored Jan 24, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents 719e715 + 484f853 commit 47f7d93
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/python/visclaw/data.py
Original file line number Diff line number Diff line change
@@ -844,6 +844,8 @@ def __init__(self, name, plot_type, plotaxes):
self.add_attribute('imshow_cmap',colormaps.yellow_red_blue)
self.add_attribute('imshow_cmin',None)
self.add_attribute('imshow_cmax',None)
self.add_attribute('imshow_norm', None)
self.add_attribute('imshow_alpha', None)


elif plot_type in ['2d_contour', '2d_contourf']:
11 changes: 9 additions & 2 deletions src/python/visclaw/frametools.py
Original file line number Diff line number Diff line change
@@ -816,6 +816,7 @@ def plotitem2(framesoln, plotitem, current_data, stateno):
'patchedges_show','patchedges_color','add_colorbar',
'pcolor_cmap','pcolor_cmin','pcolor_cmax',
'imshow_cmap','imshow_cmin','imshow_cmax',
'imshow_norm', 'imshow_alpha',
'contour_levels','contour_nlevels','contour_min','contour_max',
'contour_colors','contour_cmap','contour_show',
'fill_cmap','fill_cmin','fill_cmax','fill_colors',
@@ -906,12 +907,18 @@ def plotitem2(framesoln, plotitem, current_data, stateno):
pp['imshow_cmin'] = np.min(var)
if pp['imshow_cmax'] in ['auto',None]:
pp['imshow_cmax'] = np.max(var)
color_norm = Normalize(pp['imshow_cmin'],pp['imshow_cmax'],clip=True)

if pp['imshow_norm'] in ["auto", None]:
color_norm = Normalize(pp['imshow_cmin'],pp['imshow_cmax'],clip=True)
else:
color_norm = pp['imshow_norm']

xylimits = (X_edge[0,0],X_edge[-1,-1],Y_edge[0,0],Y_edge[-1,-1])
pobj = plt.imshow(np.flipud(var.T), extent=xylimits, \
cmap=pp['imshow_cmap'], interpolation='nearest', \
norm=color_norm)
norm=color_norm, \
alpha=pp["imshow_alpha"]
)

if pp['celledges_show']:
# This draws cell edges for this level.

0 comments on commit 47f7d93

Please sign in to comment.