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

root/gliderproc/trunk/MATLAB/opnml/FEM/newstickplot.m

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

Initial import of Stark code.

Line 
1 function h=stickplot(t,u,v,ax,varargin)
2 %STICKPLOT plot timeseries of a vector
3 % STICKPLOT plots a timeseries of direction vectors on the
4 % current axes.
5 %
6 %  Input: time - time vector
7 %         u    - east/west component of the vector series
8 %         v    - north/south component of the vector series
9 %         ax   - a 4x1 vector indicating the region of the
10 %                time series to zoom in on.  This is necessary
11 %                for the proper scaling of the direction and
12 %                magnitude of the vectors.
13 % Output: h    - handle to the line object drawn           
14 %           
15 % NOTE: do not resize the window or axes AFTER STICKPLOT
16 %       has drawn the vectors.  The east/west north/south
17 %       magnitudes will no longer be scaled correctly.
18 %
19 % PN/PV pairs accepted by STICKPLOT:
20 %    Voffset - amount to displace the stickplot vertically
21 %
22
23 %
24 % Written by : Brian O. Blanton
25 % Fall 1997
26 % Fall 2002: added varargins
27
28 if nargin==0,disp('Call as: hv=stickplot(time,u,v,ax,pn1,pv1,...)');return;end
29
30 % Default propertyname values
31 Voffset=0.;
32 % Strip off propertyname/value pairs in varargin not related to
33 % "line" object properties.
34 k=1;
35 while k<length(varargin),
36   switch lower(varargin{k}),
37     case 'voffset',
38       Voffset=varargin{k+1};
39       varargin([k k+1])=[];
40     otherwise
41       k=k+2;
42    end
43 end
44
45 axis(ax);   
46 pos = get(gca,'Position');
47 pap = get(gcf,'PaperPosition');
48 hwratio = (pos(4)*pap(4))/(pos(3)*pap(3));
49              
50 dt = ax(2)-ax(1);
51 dv = ax(4)-ax(3);
52 sf = hwratio*dt/dv;
53 s = [0; 1; 0];
54 n = length(t);
55 us = u*sf;   
56 vec = zeros( n*3, 2 );
57 id = (1:3');
58 for i=1:n   
59    vec(id,:) = s*[us(i), v(i)];
60    vec(id,1) = vec(id,1)+ones(3,1)*t(i);
61    id = id+3;
62 end         
63              
64 h=line(vec(:,1),vec(:,2)+Voffset,varargin{:});
65 if nargout==1,hstick=h;,end
66 axis(ax)     
67
68 %
69 %        Brian O. Blanton
70 %        Department of Marine Sciences
71 %        12-7 Venable Hall
72 %        CB# 3300
73 %        University of North Carolina
74 %        Chapel Hill, NC
75 %                 27599-3300
76 %
77 %        brian_blanton@unc.edu
78 %
79 %        Fall 2002
Note: See TracBrowser for help on using the browser.