Skip to content

Commit

Permalink
Choose default value for skip_patches_outside_xylimits base on mapc2p
Browse files Browse the repository at this point in the history
Instead of always setting to True if not set by user, set to False
if there is a mapc2p function for some item, since it doesn't work
properly in this case.  clawpack#278
  • Loading branch information
rjleveque committed Sep 22, 2020
1 parent 66244db commit 5f0485e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/python/visclaw/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ def __init__(self, name, plotfigure):
self.add_attribute('afteraxes',None)
self.add_attribute('xlimits',None)
self.add_attribute('ylimits',None)
self.add_attribute('skip_patches_outside_xylimits',True)
self.add_attribute('skip_patches_outside_xylimits',None)
self.add_attribute('scaled',False) # true so x- and y-axis scaled same
self.add_attribute('image',False) # true so x- and y-axis scaled same
# and plot bounds tight
Expand Down
42 changes: 33 additions & 9 deletions src/python/visclaw/frametools.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,23 @@ def plot_frame(framesolns,plotdata,frameno=0,verbose=False):
beforeaxes = getattr(plotaxes,'beforeaxes',None)
current_data = run_str_or_func(beforeaxes,current_data)

skip_patches_outside_xylimits = plotaxes.skip_patches_outside_xylimits
print('+++ skip_patches_outside_xylimits = ', \
skip_patches_outside_xylimits)
if skip_patches_outside_xylimits is None:
# User didn't set. Set to True unless there's a mapped grid

MappedGridExists = plotdata.mapc2p
if not MappedGridExists:
# check every item in case there's a mapc2p:
for itemname in plotaxes._itemnames:
plotitem = plotaxes.plotitem_dict[itemname]
MappedGridExists = MappedGridExists or \
(plotitem.mapc2p is not None)

skip_patches_outside_xylimits = not MappedGridExists
print('+++ setting skip_patches_outside_xylimits to ', \
skip_patches_outside_xylimits)

# NOTE: This was rearranged December 2009 to
# loop over patches first and then over plotitems so that
Expand All @@ -206,10 +223,9 @@ def plot_frame(framesolns,plotdata,frameno=0,verbose=False):
# loop over patches:
# ----------------

num_skipped = 0
skip_patches_outside_xylimits = \
getattr(plotaxes,'skip_patches_outside_xylimits',True)

num_skipped = 0

for stateno,state in enumerate(framesoln.states):

patch = state.patch
Expand Down Expand Up @@ -332,7 +348,7 @@ def plot_frame(framesolns,plotdata,frameno=0,verbose=False):
# end of loop over plotitems
# end of loop over patches

if False and num_skipped > 0:
if num_skipped > 0:
# possible warning message:
print('Skipped plotting %i patches not visible' % num_skipped)

Expand Down Expand Up @@ -1080,11 +1096,19 @@ def printfig(fname='',frameno='', figno='', format='png', plotdir='.', \

if kml_figsize is not None:
fig.set_size_inches(kml_figsize[0],kml_figsize[1])
a.set_frame_on(False)
plt.subplots_adjust(top = 1, bottom = 0, right = 1, left = 0,
hspace = 0, wspace = 0)
plt.margins(0,0)
plt.savefig(fname, transparent=True, bbox_inches='tight',dpi=kml_dpi)

if 0:
# original:
plt.savefig(fname, transparent=True, bbox_inches='tight', \
pad_inches=0,dpi=kml_dpi)

else:
#a.set_frame_on(False)
plt.subplots_adjust(top = 1, bottom = 0, right = 1, left = 0,
hspace = 0, wspace = 0)
plt.margins(0,0)
plt.savefig(fname, transparent=True, bbox_inches='tight',
dpi=kml_dpi) #, pad_inches=0)
else:
plt.savefig(fname, bbox_inches=bbox_inches)

Expand Down

0 comments on commit 5f0485e

Please sign in to comment.