0
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1 % IPLOT provides an intelligent plotting tool for LTPDA.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
3 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
4 % DESCRIPTION: IPLOT provides an intelligent plotting tool for LTPDA.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
5 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
6 % CALL: hfig = iplotyy (a1,a2,pl)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
7 % [hfig, hax] = iplotyy (a1,a2,pl)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
8 % [hfig, hax, hli] = iplotyy (a1,a2,pl)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
9 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
10 % INPUTS: pl - a parameter list
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
11 % a1 - input analysis object for left y-axis
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
12 % a2 - input analysis object for right y-axis
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
13 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
14 % NOTE: the two input AOs must be the same data type.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
15 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
16 % OUTPUTS: hfig - handles to figures
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
17 % hax - handles to axes
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
18 % hli - handles to lines
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
19 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
20 % <a href="matlab:utils.helper.displayMethodInfo('ao', 'iplotyy')">Parameters Description</a>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
21 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
22 % VERSION: $Id: iplotyy.m,v 1.14 2011/04/08 08:56:15 hewitson Exp $
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
23 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
24 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
25
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
26 function varargout = iplotyy(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
27
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
28 import utils.const.*
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
29
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
30 %% Check if this is a call for parameters
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
31 if utils.helper.isinfocall(varargin{:})
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
32 varargout{1} = getInfo(varargin{3});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
33 return
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
34 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
35
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
36 utils.helper.msg(msg.PROC3, 'running %s/%s', mfilename('class'), mfilename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
37
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
38 % Collect input variable names
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
39 in_names = cell(size(varargin));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
40 for ii = 1:nargin,in_names{ii} = inputname(ii);end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
41
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
42 % Check inputs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
43 if nargin ~= 2 && nargin ~= 3
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
44 error('### Incorrect inputs');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
45 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
46
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
47 % Collect arrays
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
48 if nargin >= 2
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
49 a1 = varargin{1};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
50 a2 = varargin{2};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
51 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
52 if ~isa(a1, 'ao') || ~isa(a2, 'ao')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
53 error('### Please input two AOs followed by plists');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
54 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
55
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
56 % Collect plists
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
57 if nargin >= 3
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
58 pl = parse(varargin{3:end}, getDefaultPlist);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
59 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
60 pl = getDefaultPlist;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
61 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
62
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
63 % Check size of input arrays
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
64 if numel(a1) ~= numel(a2) || numel(a1) ~= 1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
65 error('### Input two AOs.');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
66 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
67
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
68 % get data type of a1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
69 dtype1 = class(a1.data);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
70 % get data type of a2
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
71 dtype2 = class(a2.data);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
72 % check two arrays
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
73 if ~strcmp(dtype1, dtype2)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
74 error('### The two input AOs should contain the same data type.');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
75 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
76
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
77 dtype = dtype1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
78
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
79 %% Now plot all the objects on separate figures
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
80
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
81 switch dtype
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
82 case 'fsdata'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
83 [hfig, hax, hli] = xy_plot(a1,a2,pl);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
84 case 'tsdata'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
85 [hfig, hax, hli] = xy_plot(a1,a2,pl);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
86 case 'cdata'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
87 error('### Currently unsupported');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
88 case 'xydata'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
89 [hfig, hax, hli] = xy_plot(a1,a2,pl);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
90 otherwise
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
91 error('### Unsupported data type: %s', dtype);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
92 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
93
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
94 %% Deal with outputs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
95 if nargout == 1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
96 varargout{1} = hfig;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
97 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
98 if nargout == 2
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
99 varargout{1} = hfig;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
100 varargout{2} = hax;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
101 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
102 if nargout == 3
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
103 varargout{1} = hfig;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
104 varargout{2} = hax;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
105 varargout{3} = hli;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
106 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
107
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
108 if nargout > 3
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
109 error('### Incorrect number of outputs');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
110 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
111
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
112 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
113
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
114 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
115 % XY plot
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
116 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
117 function [hf, ha, hl] = xy_plot(a1,a2,pl)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
118
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
119 switch class(a1.data)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
120 case 'fsdata'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
121 pl = parse(pl, getDefaultPlist('Frequency-series plot'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
122 XLabelString = 'Frequency';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
123 x1 = a1.data.getX;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
124 y1 = a1.data.getY;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
125 x2 = a2.data.getX;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
126 y2 = a2.data.getY;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
127 % Title string
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
128 titleString = '';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
129 case 'tsdata'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
130 pl = parse(pl, getDefaultPlist('Time-series plot'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
131 XLabelString = 'Time';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
132 % Collect T0s
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
133 T0(1) = inf;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
134 if a1.data.t0.utc_epoch_milli/1000 < T0(1)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
135 T0(1) = floor(a1.data.t0.utc_epoch_milli/1000);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
136 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
137 T0(2) = inf;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
138 if a2.data.t0.utc_epoch_milli/1000 < T0(2)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
139 T0(2) = floor(a2.data.t0.utc_epoch_milli/1000);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
140 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
141
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
142 % deal with time-offsets
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
143 toff(1) = a1.data.t0.utc_epoch_milli/1000 - T0(1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
144 toff(2) = a2.data.t0.utc_epoch_milli/1000 - T0(1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
145 torigin(1) = time(T0(1));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
146 torigin(2) = time(T0(2));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
147 % need t0 offset for this time-series
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
148 x1 = a1.data.getX + toff(1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
149 y1 = a1.data.getY;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
150 x2 = a2.data.getX + toff(2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
151 y2 = a2.data.getY;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
152 % Title string
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
153 titleString = sprintf('Time origin: %s', char(torigin(1)));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
154 case 'xydata'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
155 pl = parse(pl, getDefaultPlist('X-Y plot'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
156 XLabelString = 'X';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
157 x1 = a1.data.getX;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
158 y1 = a1.data.getY;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
159 x2 = a2.data.getX;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
160 y2 = a2.data.getY;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
161 % Title string
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
162 titleString = '';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
163 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
164
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
165 % Parameters
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
166 colL = find(pl, 'LeftColor');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
167 colR = find(pl, 'RightColor');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
168 styleL = find(pl, 'LeftLineStyle');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
169 styleR = find(pl, 'RightLineStyle');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
170 yscaleL = find(pl, 'LeftYScale');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
171 xscaleL = find(pl, 'LeftXScale');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
172 yscaleR = find(pl, 'RightYScale');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
173 xscaleR = find(pl, 'RightXScale');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
174
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
175 pltfcn = 'plot';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
176 if strcmp(xscaleL, 'log') && strcmp(xscaleR, 'log') && ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
177 strcmp(yscaleL, 'log') && strcmp(yscaleR, 'log')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
178 pltfcn = 'loglog';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
179 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
180 if strcmp(xscaleL, 'lin') && strcmp(xscaleR, 'lin') && ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
181 strcmp(yscaleL, 'log') && strcmp(yscaleR, 'log')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
182 pltfcn = 'semilogy';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
183 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
184 if strcmp(xscaleL, 'log') && strcmp(xscaleR, 'log') && ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
185 strcmp(yscaleL, 'lin') && strcmp(yscaleR, 'lin')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
186 pltfcn = 'semilogx';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
187 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
188
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
189 % Make a new figure
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
190 hf = figure;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
191
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
192 % Plot
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
193 [ha,H1,H2] = plotyy(x1,y1,x2,y2,pltfcn);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
194 hl = [H1 H2];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
195 % Set grid
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
196 grid(ha(1), 'on');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
197 grid(ha(2), 'on');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
198
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
199 % Line color
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
200 set(H1, 'Color', colL);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
201 set(H2, 'Color', colR);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
202 % Line style
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
203 set(H1, 'LineStyle', styleL);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
204 set(H2, 'LineStyle', styleR);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
205 % Axis color
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
206 set(ha(1), 'XColor', 'k', 'YColor', colL);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
207 set(ha(2), 'XColor', 'k', 'YColor', colR);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
208 % Axis scales
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
209 set(ha(1), 'YScale', yscaleL);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
210 set(ha(1), 'XScale', xscaleL);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
211 set(ha(2), 'YScale', yscaleR);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
212 set(ha(2), 'XScale', xscaleR);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
213
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
214 % Set y label 1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
215 ylabel(ha(2), [fixlabel(utils.plottools.label(a2.name)) ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
216 ' ' ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
217 fixlabel(char(a1.data.yunits)) ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
218 ]);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
219 % Set y label 2
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
220 ylabel(ha(1), [fixlabel(utils.plottools.label(a1.name)) ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
221 ' ' ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
222 fixlabel(char(a2.data.yunits))...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
223 ]);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
224 % Set x label
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
225 xlabel(ha(1), [XLabelString ' ' char(a1.data.xunits)]);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
226
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
227 % Print title
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
228 title(titleString);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
229
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
230 end % End fs_plot
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
231
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
232
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
233 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
234 % Get Info Object
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
235 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
236 function ii = getInfo(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
237 if nargin == 1 && strcmpi(varargin{1}, 'None')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
238 sets = {};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
239 pl = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
240 elseif nargin == 1&& ~isempty(varargin{1}) && ischar(varargin{1})
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
241 sets{1} = varargin{1};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
242 pl = getDefaultPlist(sets{1});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
243 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
244 sets = {'Time-series Plot', 'Frequency-series Plot', 'Y Plot', 'X-Y Plot', '3D Plot'};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
245 % get plists
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
246 pl(size(sets)) = plist;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
247 for k = 1:numel(sets)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
248 pl(k) = getDefaultPlist(sets{k});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
249 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
250 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
251 % Build info object
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
252 ii = minfo(mfilename, 'ao', 'ltpda', utils.const.categories.output, '$Id: iplotyy.m,v 1.14 2011/04/08 08:56:15 hewitson Exp $', sets, pl);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
253 ii.setModifier(false);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
254 ii.setArgsmin(2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
255 ii.setOutmin(0);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
256 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
257
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
258 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
259 % Get Default Plist
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
260 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
261 function plout = getDefaultPlist(set)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
262 persistent pl;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
263 persistent lastset;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
264 if exist('pl', 'var')==0 || isempty(pl) || ~strcmp(lastset, set)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
265 pl = buildplist(set);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
266 lastset = set;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
267 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
268 plout = pl;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
269 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
270
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
271 function out = buildplist(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
272
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
273 set = '';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
274 if nargin == 1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
275 set = varargin{1};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
276 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
277
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
278 % Get the LTPDA color set for lines
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
279 colors = getappdata(0,'ltpda_default_plot_colors');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
280
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
281 out = plist(...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
282 'LeftColor', colors{1}, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
283 'RightColor', colors{2}, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
284 'LeftLineStyle', '-', ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
285 'RightLineStyle', '-');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
286
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
287 switch lower(set)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
288 case 'frequency-series plot'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
289 out.append(...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
290 'LeftYScale', 'log', ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
291 'RightYScale', 'log', ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
292 'LeftXScale', 'log', ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
293 'RightXScale', 'log');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
294 case 'time-series plot'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
295 out.append(...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
296 'LeftYScale', 'lin', ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
297 'RightYScale', 'lin', ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
298 'LeftXScale', 'lin', ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
299 'RightXScale', 'lin');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
300 case 'x-y plot'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
301 out.append(...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
302 'LeftYScale', 'lin', ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
303 'RightYScale', 'lin', ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
304 'LeftXScale', 'lin', ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
305 'RightXScale', 'lin');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
306 case '3d plot'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
307 case 'y plot'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
308 otherwise
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
309 error('### Unknown set [%s]', set);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
310 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
311 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
312
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
313
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
314 % Perform some substitutions on the labels
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
315 function ss = fixlabel(ss)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
316
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
317 wasCell = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
318 if ~iscell(ss)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
319 ss = {ss};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
320 wasCell = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
321 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
322
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
323 for kk=1:numel(ss)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
324 s = ss{kk};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
325
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
326 % Replace all ^(...) with ^{...}
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
327 j = 1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
328 while j<numel(s)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
329 if strcmp(s(j:j+1), '^(')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
330 % find next )
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
331 for k=1:numel(s)-j+1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
332 if s(j+k) == ')'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
333 s(j+1) = '{';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
334 s(j+k) = '}';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
335 break;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
336 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
337 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
338 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
339 j = j + 1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
340 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
341 % Replace all .^ with ^
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
342 s = strrep(s, '.^', '^');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
343
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
344 % reduce size
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
345 if length(s) > 25
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
346 addStr = '...';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
347 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
348 addStr = '';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
349 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
350 ssize = min(25, length(s));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
351 s = [s(1:ssize) addStr];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
352
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
353 ss(kk) = {s};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
354 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
355
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
356
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
357 if ~wasCell
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
358 ss = ss{1};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
359 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
360
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
361 end
|