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

root/gliderproc/trunk/MATLAB/opnml/FCAST_1.2/matlab_cen/colorband_points.m

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

Initial import of Stark code.

Line 
1 %-----------------------------------------------------------------------
2 % [smin,smax,ibw]=colorband_points(x,y,scalar,pointsize,wantbar,smin,smax,ibw)
3 % This function creates a color plot of data using
4 % Matlab5.1 commands
5 %-----------------------------------------------------------------------
6 function [smin,smax,ibw]=colorband_points(x,y,scalar,pointsize,wantbar,smin,smax,ibw)
7 %
8 % Echo scalar range to screen
9 %
10 fprintf(1,'Scalar Range: %f to %f\n',min(min(scalar)),max(max(scalar)))
11 %
12 % Set color banding settings (if 4 arguments are sent to function)
13 %
14 if nargin == 5
15    smin=input('Enter min contour level desired: ');
16    smax=input('Enter max contour level desired: ');
17    ibw  =input('Enter the contour interval:      ');
18 end
19 %
20 % Set color map for bands
21 %
22 clear cmap;
23 cval=smin:ibw:smax;
24 nband=(2*ibw+smax-smin)/ibw;
25 cmapjet=jet;
26 size(cmapjet);
27 njet=ans(1);
28 cmap(1,:)=[0 0 0];
29 for i=2:nband-1
30    cmap(i,:)=cmapjet(1+round((njet-1)*(i-2)/(nband-3)),:);
31 end
32 cmap(nband,:)=[1 1 1];
33 colormap(cmap);caxis([smin-ibw smax+ibw]);
34 %
35 % Create fem colorfill plot of a random triangle to set color map
36 % (then remove fem colorfill plot)
37 %
38 if wantbar == 1
39    in=[1 2 3 3];hc=colormeshm(in,x,y,scalar);
40    colormap(cmap);caxis([smin-ibw smax+ibw]);
41    hbar=colorbar;
42    set(hbar,'ytick',cval);
43    set(hbar,'ticklength',[0.05 0.025]);
44    delete(hc);
45 end
46 %
47 % Sort scalar and reindex (x,y) accordingly
48 %
49 [scalars,is]=sort(scalar);
50 for i=1:length(scalars)
51    xs(i,1)=x(is(i));
52    ys(i,1)=y(is(i));
53 end
54 %
55 % Identify scalar index values which define range of each band
56 %
57 ibandi=zeros(nband,2);
58 for iband=1:length(cval)
59    if scalars(1) < cval(iband)
60       ibandi(iband,1)=1;
61       break;
62    end
63 end
64 for i=1:length(scalars)
65    if scalars(i) > cval(iband)
66       ibandi(iband,2)=i-1;
67       iband=iband+1;
68       ibandi(iband,1)=i;
69       if iband == nband; break; end;
70    end
71 end
72 ibandi(iband,2)=length(scalars);
73 if iband <= nband
74    for i=iband+1:nband
75       ibandi(i,1)=0;
76       ibandi(i,2)=0;
77    end
78 end
79 %
80 % Make color plot
81 %
82 hold on;
83 for iband=1:nband-1
84    if ibandi(iband,1) ~= 0
85    hp=plot(xs(ibandi(iband,1):ibandi(iband,2),1),ys(ibandi(iband,1):ibandi(iband,2),1),'k.');
86    set(hp,'MarkerSize',pointsize);
87    set(hp,'Color',cmap(iband,:));
88    end
89 end
90 if ibandi(nband,1) ~= 0;
91    hp=plot(xs(ibandi(nband,1):ibandi(nband,2),1),ys(ibandi(nband,1):ibandi(nband,2),1),'ks');
92    set(hp,'MarkerSize',pointsize/3.0);
93 end
94 xlabel(['Data Range: ',num2str(min(scalar)),' to ',num2str(max(scalar))])
95 drawnow;
96 clear cmap;
97 %-----------------------------------------------------------------------
Note: See TracBrowser for help on using the browser.