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

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

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

Initial import of Stark code.

Line 
1
2         function [hplot,hleg] = colordots(varargin)
3
4 %
5 %   colordots plots data as dot-patches on a current axis
6 %
7 %   colordots requires the following arguments:
8 %               data            - array in the format [x y q]
9 %                                 where q is the scalar to be displayed
10 %               leg (opt)       - string of legend text
11 %               pctsc (opt)     - percent scale for colordots
12 %                                 (default is 2)
13 %                               
14 %   [hplot,hleg] = colordots(data1, leg1, pctsc);
15 %
16 % Calls: none
17 %
18 %  Catherine R. Edwards
19 %  Last modified: 31 Jul 2001
20 %
21
22
23 % PROCESS THE INPUT ARGUMENTS -- Copy incoming cell array
24 input_cell=varargin;
25 nargs=length(input_cell);
26
27 % DEFINE ERROR STRINGS
28 err1=['Incorrect number of arguments to COLORDOTS'];
29 err2=['Each set of data must have a legend.'];
30 err3=['Incorrect ordering of arguments.'];
31
32 % Length of input_cell must be between 1 and 3, inclusive.
33 if nargs<1 |  nargs>3
34    error(err1)
35 end
36
37 % Set num patches and part out input_cell
38 if nargs==1
39   data1=input_cell{1};
40 elseif nargs==2
41   data1=input_cell{1};
42   if isstr(input_cell{2})
43     leg1=input_cell{2};
44   elseif sum(size(input_cell{2}))>2
45     pctsc=input_cell{2};
46   end
47 elseif nargs==3
48   data1=input_cell{1}; leg1=input_cell{2}; pctsc=input_cell{3};
49 end
50
51 if ~exist('pctsc'); pctsc=2; end
52 if isstr(pctsc); error(err3); end
53 if ~exist('leg1'); nargout=1; end
54
55 % SCALE DATA TO RENDERED WINDOW SCALE
56
57 RLs= get(gca,'XLim');xr=RLs(2)-RLs(1);
58 RLs= get(gca,'YLim');yr=RLs(2)-RLs(1);
59
60 if(xr==0|yr==0)
61    error('Axes must have been previously set for PATCHPLOT to work');
62 end
63 pct=0.5*pctsc*sqrt(xr*xr+yr*yr)/100;
64
65 % arrange data
66
67 if isempty(data1); else;
68   s1=size(data1); if s1(1)~=3; data1=data1'; end
69   x1=data1(1,:); y1=data1(2,:); q1=data1(3,:); Q=q1;
70   hold on;
71 end
72 hdot=plot(5,5,'ob','visible','off');
73
74 cl=get(gca,'clim'); qmax=ceil(10*max(Q))/10; qmin=fix(10*min(Q))/10;
75 dq=qmax-qmin;
76 if(cl==[0 1])
77   cl=[qmin qmax];
78 else
79   cl=[min(qmin,cl(1)) max(qmax,cl(2))];
80 end
81
82 the=repmat(linspace(0,2*pi,501),length(x1),1)';
83 xx=repmat(x1,501,1); yy=repmat(y1,501,1); qq=repmat(q1,501,1);
84 hdots=patch(pct*cos(the)+xx,pct*sin(the)+yy,qq);
85 set(hdots,'edgecolor','none');
86 colorbar;
87
88 % assign handles to plots
89
90 hplot=hdots;
91 if exist('leg1');
92   hleg=legend(hdot,leg1);
93 end
94
95 return;
Note: See TracBrowser for help on using the browser.