Code covered by the BSD License  

Highlights from
contourfcmap: filled contour plot with precise colormap

5.0

5.0 | 2 ratings Rate this file 33 Downloads (last 30 days) File Size: 3.24 KB File ID: #29638
image thumbnail

contourfcmap: filled contour plot with precise colormap

by Kelly Kearney

 

06 Dec 2010 (Updated 19 Oct 2011)

Creates a filled contour plot, with more precise control over colors than contourf.

| Watch this File

File Information
Description

This function creates a shaded contour plot, similar to that created by the contourf function. However, the relationship between a contourf plot and its colormap (i.e. exactly which color corresponds to each contour interval), can often be confusing and inconsistent, especially if your contour lines are not evenly spaced. This function instead allows the user to specify exactly which colors to use in each interval, and also to choose colors for regions that exceed the contour line limits.

MATLAB release MATLAB 7.10 (2010a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (4)
09 May 2011 Tjaart de Wit

Great function! Thanks

18 Oct 2011 Aurelien Queffurust

Hi,
I wanted to test your code but:
the minmax function which is required by your code is not shipped .

Another remark:
You have forgotten a bracket in the given example in the header of M-file:
[x,y] = meshgrid(linspace(0,1,100)
should be:
[x,y] = meshgrid(linspace(0,1,100))

Now waiting for minmax.m before rating.

Thanks,

Aurélien

19 Oct 2011 Kelly Kearney

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.

10 May 2012 Earle Wilson

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);

Please login to add a comment or rating.
Updates
07 Dec 2010

minor grammatical fix in description

19 Oct 2011

Fixed accidental omission of helper function in colorbar generation (minmax). Also corrected minor typo in example and added more informative example image.

Tag Activity for this File
Tag Applied By Date/Time
contour Kelly Kearney 07 Dec 2010 08:34:29
filled Kelly Kearney 07 Dec 2010 08:34:29
contourf Kelly Kearney 07 Dec 2010 08:34:29
contor Robin Martin 10 Dec 2010 01:49:32

Contact us at files@mathworks.com