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