SCM

SCM Repository

[batman] Annotation of /SplineFitBATMAN_MATLABcode/stackplot.m
ViewVC logotype

Annotation of /SplineFitBATMAN_MATLABcode/stackplot.m

Parent Directory Parent Directory | Revision Log Revision Log


Revision 346 - (view) (download)

1 : jie 346 function [offset_out] = stackplot(D,x,lab,s,zlines,ptype)
2 :     % [offset] = stackplot(D,x,lab,s,zlines,ptype]) - plot a series of 'spectra', stacked up the page
3 :     %
4 :     % D = (nXm) of data, each row is a separate spectrum
5 :     % x = (1Xm) vector giving x axis values. if == [1] then plots vs. indices.
6 :     % lab = (nX1) vector of strings giving labels for spectra.
7 :     % If lab==1, numbers from 1 to n. If lab==0 then no labels.
8 :     % s = (nX1) Vector giving y-spacing of plots.
9 :     % If s=='zero', chooses own spacing
10 :     % If s not given, chooses own spacing
11 :     % zlines = (1x1) if 1 then plots zero lines (default 0)
12 :     % ptype = (string) plot line type specification (optional)
13 :     %
14 :     % offset = (nX1) vector of calculated offsets for each row of D
15 :     %
16 :     % written 290999 TMDE
17 :     % revised 041199 to include x axis values
18 :     % revised 250200 to label spectra if required.
19 :     % revised 090102 to not require x argument
20 :     % revised 060308 to have separate switch for zero lines. Also removed grid.
21 :     % (c) 1999-2008 Dr. Timothy M D Ebbels, Imperial College, London
22 :     % modified by 120213 JHao
23 :    
24 :     if (nargin<2) x = 1:size(D,2); end
25 :     if (nargin<5) zlines=0; end
26 :    
27 :     tol=0.1;
28 :     dylab = 0.5;
29 :     [r,c] = size(D);
30 :    
31 :     if (ischar(x)) x = str2num(x); end
32 :     if (x==1) x = 1:c; end
33 :    
34 :     if (r==1)
35 :     offset = 0;
36 :     else
37 :     if (~exist('s','var') | strcmp(s,'zero'))
38 :     o1 = max(-(diff(D)'));
39 :     o1 = [0,o1 + max(o1)*tol];
40 :     offset=cumsum(o1);
41 :     if(exist('s','var') & s=='zero')
42 :     o2 = max(D');
43 :     o2 = o2(1:r-1);
44 :     o2 = [0,o2 + max(o2)*tol];
45 :     offset = max([o1;o2]);
46 :     offset = cumsum(offset);
47 :     end
48 :     else
49 :     offset = 0:s:(r-1)*s;
50 :     end
51 :     end
52 :     off = repmat(offset',1,c);
53 :     D = D + off;
54 :    
55 :     if (exist('ptype','var'))
56 :     plot(x,D',ptype)
57 :     else
58 :     plot(x,D')
59 :     end
60 :    
61 :     if zlines
62 :     hold on
63 :     plot(x,off','k:')
64 :     hold off
65 :     end
66 :    
67 :     % Labels
68 :     %%%%% modified by JHao
69 :     axis tight
70 :     %%%%%%%%%%
71 :    
72 :     if (exist('lab','var'))
73 :     if iscell(lab) lab = char(lab); end
74 :     if (lab~=0)
75 :     if (lab==1) lab = num2str([1:r]'); end
76 :     a = axis;
77 :     xpos = a(1) + 0.05*(a(2)-a(1));
78 :     xpos = ones(r,1)*xpos;
79 :     ypos = offset + dylab*max(diff(offset));
80 :     text(xpos,ypos,lab);
81 :     end
82 :     end
83 :    
84 :     axis tight
85 :     % Allocate output
86 :    
87 :     if (nargout>0) offset_out = off; end

R-Forge@R-project.org
ViewVC Help
Powered by ViewVC 1.0.0  
Thanks to:
Vienna University of Economics and Business University of Wisconsin - Madison Powered By FusionForge