MATLAB: Odd triangles using Matlab’s contour and contourf functions

contourcountorfdelaunay triangulation

Hi,
I make contour maps using MATLAB's contourf function and I've always experienced these odd triangular regions. On the edges of the map, some of the triangles, but not all, appear solid colored when they should clearly have isochrones running through them.
See the map I've made here http://i.imgur.com/ES4Tq.jpg (The solid triangles appear in the top right along the edges of the data)
(Ignore the red vs. black circles. They are the locations of the data points; the red corresponds to points that were interpolated but this has no affect the contouring.)
The above contour map is called using this line of code:
[C,h,cf] =contourf(gca,XI, YI, flipud(plotMatrix), MIN_TIME:dTcont:MAX_TIME);
and those values are as follows:
plotMatrix =
Columns 1 through 10
NaN 446.7667 447.7333 448.4000 448.6000 NaN NaN NaN 446.8333 446.5333
448.2667 451.7667 451.3333 450.3667 449.9000 446.5465 NaN 442.8725 442.5158 440.3006
445.9226 448.1227 444.6667 443.8333 443.3333 442.3333 440.8547 439.4667 440.1333 438.0667
440.9667 444.8000 443.7000 442.8000 442.2667 441.3910 440.5554 440.5333 440.7667 440.3667
NaN 441.2437 442.4314 441.7667 441.6333 441.8000 441.3000 441.7000 441.7333 441.7000
NaN 437.7451 440.9333 440.4333 440.6333 440.8667 441.9000 442.4000 442.8000 443.0333
NaN 434.4667 439.5667 439.4000 440.4667 440.7667 441.5000 442.0333 442.7333 443.2667
435.1333 435.9333 437.1000 438.7000 440.3333 440.8000 441.3667 442.0000 442.6219 443.2333
436.1667 437.0000 437.6333 440.0667 440.3333 440.8000 441.5000 442.1000 442.8000 443.6333
438.5667 437.9667 438.7000 439.2667 439.9333 440.7333 441.6000 442.4667 443.1333 443.6667
438.3648 438.8000 439.3333 440.5667 440.6333 441.6333 442.0667 442.5000 443.0333 443.7667
437.9188 440.5000 441.0667 441.2667 441.3000 441.9667 442.4667 443.2667 443.7000 444.5667
NaN 440.6333 441.9681 441.8333 442.1667 442.4333 443.5167 444.3874 444.9260 445.4945
NaN 440.0667 441.8333 442.4333 442.3667 443.8333 444.6212 444.8409 NaN NaN
NaN NaN NaN 441.5975 443.8667 444.3333 NaN NaN NaN NaN
NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Columns 11 through 12
445.8667 NaN
436.5667 436.9699
437.2000 437.5000
439.1333 438.7667
441.2224 440.5667
442.8000 442.4333
443.8004 444.0667
443.8667 444.3333
444.1667 444.8000
444.2667 444.9000
444.5333 445.1000
445.2000 446.1000
446.0412 445.4333
NaN NaN
NaN NaN
NaN NaN
XI =
0 7 14 21 28 35 42 49 56 63 70 77
0 7 14 21 28 35 42 49 56 63 70 77
0 7 14 21 28 35 42 49 56 63 70 77
0 7 14 21 28 35 42 49 56 63 70 77
0 7 14 21 28 35 42 49 56 63 70 77
0 7 14 21 28 35 42 49 56 63 70 77
0 7 14 21 28 35 42 49 56 63 70 77
0 7 14 21 28 35 42 49 56 63 70 77
0 7 14 21 28 35 42 49 56 63 70 77
0 7 14 21 28 35 42 49 56 63 70 77
0 7 14 21 28 35 42 49 56 63 70 77
0 7 14 21 28 35 42 49 56 63 70 77
0 7 14 21 28 35 42 49 56 63 70 77
0 7 14 21 28 35 42 49 56 63 70 77
0 7 14 21 28 35 42 49 56 63 70 77
0 7 14 21 28 35 42 49 56 63 70 77
YI =
0 0 0 0 0 0 0 0 0 0 0 0
7 7 7 7 7 7 7 7 7 7 7 7
14 14 14 14 14 14 14 14 14 14 14 14
21 21 21 21 21 21 21 21 21 21 21 21
28 28 28 28 28 28 28 28 28 28 28 28
35 35 35 35 35 35 35 35 35 35 35 35
42 42 42 42 42 42 42 42 42 42 42 42
49 49 49 49 49 49 49 49 49 49 49 49
56 56 56 56 56 56 56 56 56 56 56 56
63 63 63 63 63 63 63 63 63 63 63 63
70 70 70 70 70 70 70 70 70 70 70 70
77 77 77 77 77 77 77 77 77 77 77 77
84 84 84 84 84 84 84 84 84 84 84 84
91 91 91 91 91 91 91 91 91 91 91 91
98 98 98 98 98 98 98 98 98 98 98 98
105 105 105 105 105 105 105 105 105 105 105 105
MIN_TIME =
434.4667
dTcont =
1
MAX_TIME =
451.7667
I'd like to know if these triangles are the result of contour's use of Delaunay triangulation. I've tried to look through the contourf code but I get lost.
Also, any thoughts on how to get rid of these triangles so the maps look better?
Thanks!
Emily

Best Answer

I think your main problem is that there aren't many data, so it is hard to make nice contours out of it. Look at the bit-mapped image:
xi = 0:7:77; yi = 0:7:105;
imagesc(xi,yi,plotMatrix)
colorbar
It's pretty coarse. You can't justify using 16 contours with such data. This plot with a smaller number of contours looks better:
[XI,YI] = meshgrid(xi,yi);
MIN_TIME = 434.4667;
dTcont = 1;
MAX_TIME = 451.7667;
figure
[C,h,cf] =contourf(gca,XI, YI, flipud(plotMatrix),8);
colorbar