Page 171 - MATLAB Recipes for Earth Sciences
P. 171
166 7 Spatial Data
min(data(:,3))
ans =
-25
max(data(:,3))
ans =
20
we choose
v = -30 : 5 : 25;
The command
[c,h] = contour(XI,YI,ZI,v)
returns contour matrix c and a handle h that can be used as input to the func-
tion clabel, which labels contours automatically.
clabel(c,h)
Alternatively, the graph is labeled manually by selecting manual option in
the function clabel. This function places labels onto locations that have
been selected with the mouse. Labeling is terminated by pressing the re-
turn key.
[c,h] = contour(XI,YI,ZI,v);
clabel(c,h,'manual')
Filled contours are an alternative to the empty contours used above. This
function is used together with colorbar displaying a legend for the graph.
In addition, we plot the locations and z values of the control points (black
empty circles, text labels) (Fig. 7.6).
contourf(XI,YI,ZI,v), colorbar
hold on
plot(data(:,1),data(:,2),'ko')
text(data(:,1)+1,data(:,2),labels);
hold off
A pseudocolor plot is generated by using the function pcolor. Black con-
tours are also added at the same levels as in the above example.
pcolor(XI,YI,ZI), shading flat
hold on
contour(XI,YI,ZI,v,'k')
hold off