File Exchange

image thumbnail


version (2.81 KB) by benoit
contourf with nans filled in precisely

1 Download

Updated 03 Sep 2015

View License

The function makes a contourf plot with nans filled in gray with borders. For example, if you have a map of ocean sea surface temperature, and have nans on land 'boxes', this will plot the coast nicely (see image).
Takes the same input as contourf(x,y,z), plus (xb,yb) which are the boundary coordinates of (x,y), i.e. (xb,yb) define the coordinates of the borders of the boxes.

This now works even if there are 'lakes' within the continents.

Basically it fills the nans by extrapolating using the very good inpaint_nans.m, then it plots the contourf using this filled file, then it superimposes the filling of nans, then it draws the coast line.

Only issue I have now is that when printing to eps, you can slightly see the underlying contourf between nan boxes... If anyone knows how to deal with it, let me know!

Cite As

benoit (2020). nanContourf(xb,yb,x,y,z) (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (0)


cleaned description of function and code

commented and simplified code a bit

changed a lot. Now fills the nan boxes individually. This enables to deal with 'lakes' but creates a problem when printing to eps.

just got rid of the v2 in the top right sublot

Added an extrapolation (inpaint_nans) to get rid of the white borders of nans.

added the fact it does not work for 'lakes'

MATLAB Release Compatibility
Created with R2012a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired by: inpaint_nans