great function! This saved me many hours of working around all the bugs in contourf.
The only (minor) short coming is that this function doesn't deal with saturated low values. Eg. if you enter:
contourfcmap(x,y,z,clev,cmap,lo,hi)
and there are values in z < min(clev), they will be plotted as white spaces. This is an issue with contourf really, which I won't get into here. An easy fix is set all values in z outside the clev limits to min(clev) or max(clev). Eg.
toohigh = z>max(clev); z(toohigh) = max(clev);
loolow = z<min(clev); z(toolow) = min(clev);
Added minmax subfunction into main code (overlooked this dependency on a simple helper function in previous upload). Thanks, Karin and Aurelien, for pointing out that mistake.
Comment only