1 |
%--------------------------------------------------------------------------- |
---|
2 |
% CCPLOT(X,Y,Z,C_AXIS,SYMBOL,MARKER_SIZE) |
---|
3 |
function h=ccplot(x,y,z,c_axis,symbol,marker_size) |
---|
4 |
% ccplot Creates a color-coded plot. |
---|
5 |
% |
---|
6 |
% CCPLOT(X,Y,Z,C_AXIS,SYMBOL,MARKER_SIZE) creates a color-coded plot of |
---|
7 |
% vector Z with respect to vectors X and Y using C_AXIS to map |
---|
8 |
% values of Z to the colormap of the current figure. Data is |
---|
9 |
% plotted using SYMBOL's of MARKER_SIZE. |
---|
10 |
% |
---|
11 |
% If C_AXIS is an empty vector CCPLOT calculates C_AXIS to be |
---|
12 |
% [min(z) max(z)]. |
---|
13 |
% |
---|
14 |
% example... |
---|
15 |
% x = [0:.1:100]; |
---|
16 |
% y = sin(x); |
---|
17 |
% z = rand(1,length(y)) + 10.^y; |
---|
18 |
% subplot(2,1,1);plot3(x,y,z) |
---|
19 |
% subplot(2,1,2);ccplot(x,y,z,[],'.',20); |
---|
20 |
% |
---|
21 |
|
---|
22 |
% Author: Trevor Cooper, Marine Life Research Group/SIO |
---|
23 |
% tcooper@ucsd.edu |
---|
24 |
% December 8, 1995. |
---|
25 |
|
---|
26 |
|
---|
27 |
if(length(c_axis) == 0) |
---|
28 |
isfin = find(finite(z)); |
---|
29 |
c_axis = [min(z(isfin)) max(z(isfin))] |
---|
30 |
end |
---|
31 |
|
---|
32 |
cmap = get(gcf,'colormap'); |
---|
33 |
|
---|
34 |
index = floor( (z-c_axis(1)) / ((c_axis(2)-c_axis(1)) / size(cmap,1))); |
---|
35 |
|
---|
36 |
too_small = find(index<1); |
---|
37 |
if(length(too_small) > 0) |
---|
38 |
index(too_small)=ones(length(too_small),1); |
---|
39 |
end |
---|
40 |
|
---|
41 |
too_big = find(index>size(cmap,1)); |
---|
42 |
if(length(too_big) > 0) |
---|
43 |
index(too_big)=ones(length(too_big),1)*size(cmap,1); |
---|
44 |
end |
---|
45 |
|
---|
46 |
for j=1:size(cmap,1) |
---|
47 |
matched=find(index == j); |
---|
48 |
if(length(matched) > 0) |
---|
49 |
h=plot(x(matched), y(matched), symbol, 'color', cmap(j,:), ... |
---|
50 |
'markersize', marker_size, 'tag', 'ccplot'); |
---|
51 |
hold on; |
---|
52 |
end |
---|
53 |
end |
---|
54 |
hold on; patch(nan,nan,nan);set(gca,'clim',c_axis); |
---|
55 |
hold off; |
---|
56 |
|
---|