NCCOOS Trac Projects: Top | Web | Platforms | Processing | Viz | Sprints | Sandbox | (Wind)

root/gliderproc/trunk/MATLAB/plots/contourpm.m

Revision 495 (checked in by cbc, 12 years ago)

Initial import of Stark code.

Line 
1 function [cout, hand] = contourpm(x,y,z,ci,col)
2 % function [cout, hand] = contourpm(x,y,z,ci,col)
3 %
4 % draw positive, negative and zero contours
5 %
6 % input  :              see contour
7 %                       with the exception of the number of contourlevels
8 %                       it's used here as contourinterval !!!
9 %               col     overides 'gkr' colors
10 %                       give 'rrr' for all red lines
11 %                       'gray' gives a shaded negative area and solid lines
12 %
13 % output :              see contour
14 %
15 % uses :        nmin, nmax
16 %
17 % version 0.1.4         last change 22.11.1999
18
19 % Gerd Krahmann, LDEO June 1999
20 % removed flaw in graphics      G.K.            8.6.1999        0.1.0-->0.1.1
21 % check for empty matrices      G.K.            10.8.1999       0.1.1-->0.1.2
22 % can use ci-vector             G.K.            9.9.1999        0.1.2-->0.1.3
23 % added 'gray'                  G.K.            22.11.1999      0.1.3-->0.1.4
24
25 lip = '-';
26 liz = ':';
27 lin = '--';
28 if nargin<5
29   col = 'gkr';
30 end
31
32 if nargin==3 & isstr(z)
33   col = z;
34   [mc,nc] = size(x);
35   z = x;
36   lims = [1 nc 1 mc];
37   x = [1:nc];
38   y = [1:mc];
39 end
40 if nargin <= 2,
41     [mc,nc] = size(x);
42     lims = [1 nc 1 mc];
43     z = x;
44     if nargin == 1
45       ci = (nmax(x(:))-nmin(x(:)))/20;
46     else
47       ci = y;
48     end
49     x = [1:nc];
50     y = [1:mc];
51 else
52     lims = [min(x(:)),max(x(:)), ...
53             min(y(:)),max(y(:))];
54     if nargin == 3
55       ci = (nmax(z(:))-nmin(z(:)))/20;
56     end
57 end
58
59 % check for gray shaded plot
60 if strcmp(col,'gray')
61   gr = 1;
62   col = 'kkk';
63   zlw = 0.5;
64   lin = '-';
65 else
66   gr = 0;
67   zlw = 1.5;
68 end
69
70
71 if length(ci)==1
72   cim = fliplr([-ci:-ci:nmin(z(:))]);
73   ciz = [0,0];
74   cip = [ci:ci:nmax(z(:))];
75 else
76   cim = ci(find(ci<0));
77   ciz = [0,0];
78   cip = ci(find(ci>0));
79 end
80
81 % plot zero contours
82 if gr==1
83   contourf(x,y,z,ciz);
84   colormap(gray)
85   caxis([-1,0.5])
86 end
87 hold on
88 [c2,h2,msg] = contour3(x,y,z,ciz,[liz,col(2)]);
89 for i = 1:length(h2)
90   set(h2(i),'linewidth',zlw);
91 end
92 if ~isempty(msg)
93   error(msg);
94 end
95
96 % plot positive contours
97 if ~isempty(cip)
98   [c3,h3,msg] = contour3(x,y,z,cip,[lip,col(3)]);
99 %  if ~isempty(msg)
100 %    error(msg);
101 %  end
102   hold on
103 else
104   c3 = [];
105   h3 = [];
106 end
107
108 % plot negative contours
109 if ~isempty(cim)
110   [c1,h1,msg] = contour3(x,y,z,cim,[lin,col(1)]);
111   if ~isempty(msg)
112     error(msg);
113   end
114   hold on
115 else
116   c1 = [];
117   h1 = [];
118 end
119 c = [c1,c2,c3];
120 h = [h1;h2;h3];
121
122 for i = 1:length(h)
123   set(h(i),'Zdata',[]);
124 end
125
126 view(2);
127 set(gca,'box','on');
128
129 if nargout > 0
130     cout = c;
131     hand = h;
132 end
Note: See TracBrowser for help on using the browser.