clawpack/visclaw — pull request #81 by rjleveque (2013-09-13 01:15:05+00:00)
Title: Contourf

I suggest merging this instead of PR #80.

For contourf the colors should refer to what fills between the lines, not the lines (unlike contour).
I have introduced two alternative ways of setting colors:

Either set attributes fill_cmap, fill_cmin, and fill_cmax, e.g. for geoclaw/examples/tsunami/chile2010:

plotitem = plotaxes.new_plotitem(plot_type='2d_contourf')
plotitem.plot_var = geoplot.surface_or_depth
plotitem.contour_levels = linspace(-0.2,0.2,5)
plotitem.fill_cmap = geoplot.tsunami_colormap
plotitem.fill_cmin = -0.2
plotitem.fill_cmax = 0.2
plotitem.add_colorbar = True

or you can set plotitem.fill_colors to a list of color tuples. (corresponding to the colors parameter in contourf rather than the cmap parameter).

I made the default "extend='both' " in the call to contourf so that all data gets mapped to colors. Override this with
plotitem.kwargs = {'extend':'neither'}
in which case data outside the range of contour_levels plots as white (which is the contourf default but can be misleading).