0
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1 % GNUPLOT a gnuplot interface for AOs.
|
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: filenames = gnuplot(a,pl)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
7 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
8 % INPUTS: pl - a parameter list
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
9 % a - input analysis objects
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
10 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
11 % OUTPUTS: filenames - if gnuplot is configured to output files, then
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
12 % the filenames are returned here.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
13 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
14 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
15 % NOTE: this method requires gnuplot to be installed on the system. The
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
16 % path to the gnuplot binary can be set in the input plist with the key
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
17 % 'GNUPLOT'.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
18 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
19 % gnuplot: http://www.gnuplot.info/
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
20 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
21 % AO Plot Info
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
22 % ------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
23 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
24 % If an input AO has a filled plotinfo plist, then the options contained in
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
25 % therein will overide any other options. The recognised keys are:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
26 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
27 % 'linestyle', 'linewidth', 'color', 'marker', 'legend_on'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
28 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
29 % The possible values are all those accepted by plot.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
30 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
31 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
32 % EXAMPLES:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
33 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
34 % 1) Plot two time-series AOs on the same plot and output to a PDF file
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
35 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
36 % gnuplot(a1, a2, plist('terminal', 'pdf enhanced', ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
37 % 'output', outfile, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
38 % 'preamble', {'set title "my nice plot"', 'set key outside top right'}, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
39 % 'markerscale', 3))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
40 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
41 % 2) Plot two time-series AOs in subplots. If the AOs have markers set in
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
42 % the plotinfo, they will be scaled in size x3 from default.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
43 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
44 % gnuplot(a1, a2, plist('arrangement', 'subplots', 'terminal', 'pdf enhanced', ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
45 % 'output', outfile, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
46 % 'preamble', {'set title "my nice plot"', 'set key outside top right'}, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
47 % 'markerscale', 3))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
48 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
49 % 3) Plot two time-series AOs, each to its own output pdf file.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
50 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
51 % gnuplot(a1, a2, plist('arrangement', 'single', 'terminal', 'pdf enhanced', ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
52 % 'output', outfile, 'outdir', '.', ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
53 % 'preamble', {'set title "my nice plot"', 'set key outside top right'}, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
54 % 'markerscale', 3))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
55 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
56 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
57 % <a href="matlab:utils.helper.displayMethodInfo('ao', 'gnuplot')">Parameters Description</a>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
58 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
59 % VERSION: $Id: gnuplot.m,v 1.12 2011/04/13 04:51:36 mauro Exp $
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
60 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
61 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
62
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
63
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
64 function varargout = gnuplot(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
65
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
66
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
67 % Check if this is a call for parameters
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
68 if utils.helper.isinfocall(varargin{:})
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
69 varargout{1} = getInfo(varargin{3});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
70 return
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
71 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
72
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
73 import utils.const.*
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
74 utils.helper.msg(msg.PROC3, 'running %s/%s', mfilename('class'), mfilename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
75
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
76 % Collect input variable names
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
77 in_names = cell(size(varargin));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
78 for ii = 1:nargin,in_names{ii} = inputname(ii);end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
79
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
80 % Collect all AOs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
81 [as, ao_invars] = utils.helper.collect_objects(varargin(:), 'ao', in_names);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
82
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
83 % Apply defaults to plist
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
84 usepl = applyDefaults(getDefaultPlist, varargin{:});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
85
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
86 % Loop over input AOs and collect the different types
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
87 [timeAOs, freqAOs, yAOs, xyAOs] = collectAOs(as);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
88
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
89 fnames = {};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
90 % Do time-series
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
91 if ~isempty(timeAOs)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
92 fnames = [fnames plot_ao_set(timeAOs, usepl)];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
93 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
94 % Do freq-series
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
95 if ~isempty(freqAOs)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
96 fnames = [fnames plot_ao_set(freqAOs, usepl)];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
97 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
98
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
99 if ~isempty(xyAOs)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
100 error('Plotting xy-data objects is not yet supported.');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
101 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
102
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
103 if ~isempty(yAOs)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
104 error('Plotting c-data objects is not yet supported.');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
105 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
106
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
107 if nargout == 1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
108 varargout{1} = fnames;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
109 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
110
|
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 function fnames = plot_ao_set(as,pl)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
115
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
116 fnames = {};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
117
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
118 Na = numel(as);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
119
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
120 % Parameters
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
121 odir = pl.find('OutputDir');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
122 output = pl.find('output');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
123 terminal = pl.find('terminal');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
124 terminalOpts = pl.find('terminal options');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
125 gnuplotBin = pl.find('gnuplot');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
126
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
127 if isempty(terminal)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
128 runcmd(gnuplotBin, ' -e "help terminal"');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
129 return;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
130 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
131
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
132 if isempty(output)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
133 output = tempname;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
134 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
135 output = fullfile(odir, output);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
136 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
137
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
138 %----------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
139 % Make filenames
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
140 %----------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
141 aTmpFile = tempname;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
142 % One data file per AO
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
143 tmpData = {};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
144 for kk = 1:Na
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
145 tmpData = [tmpData {sprintf('%s_%d.dat', aTmpFile, kk)}];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
146 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
147 % One gnu file
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
148 tmpGnu = [aTmpFile '.gnu'];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
149 % Output file
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
150 [path,name,ext] = fileparts(output);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
151 if isempty(ext)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
152 output = [output '.' terminal];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
153 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
154
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
155 utils.helper.msg(utils.const.msg.PROC1, 'Output file: %s', output);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
156 utils.helper.msg(utils.const.msg.PROC1, 'Plotting %d time-series AOs...', numel(as));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
157
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
158 switch class(as(1).data)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
159 case 'tsdata'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
160 fnames = [fnames ts_plot(output, terminal, terminalOpts, tmpGnu, tmpData, as, pl)];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
161 case 'fsdata'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
162 fnames = [fnames fs_plot(output, terminal, terminalOpts, tmpGnu, tmpData, as, pl)];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
163 case 'xydata'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
164 case 'ydata'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
165 otherwise
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
166 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
167
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
168 % Clean up tmp files
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
169 for kk = 1:numel(tmpData)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
170 delete(tmpData{kk});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
171 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
172 delete(tmpGnu);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
173
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
174
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
175 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
176
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
177 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
178 % Make freq-series plot
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
179 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
180
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
181 function fnames = fs_plot(output, terminal, terminalOpts, tmpGnu, tmpData, as, pl)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
182
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
183 switch pl.find('arrangement')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
184 case 'single'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
185 fnames = write_single_freqseries_plot(terminal, terminalOpts, output, tmpGnu, tmpData, as, pl);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
186 case 'stacked'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
187 fnames = write_stacked_freqseries_plot(terminal, terminalOpts, output, tmpGnu, tmpData, as, pl);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
188 case 'subplots'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
189 error('subplots arrangement for frequency-series is not currently supported');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
190 otherwise
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
191 fnames = {};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
192 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
193
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
194 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
195
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
196 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
197 % Plots all the freq-series AOs on individual plots.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
198 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
199 function fnames = write_single_freqseries_plot(terminal, terminalOpts, output, tmpGnu, tmpData, as, pl);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
200
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
201 fnames = {};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
202 gnuplotBin = pl.find('gnuplot');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
203 Na = numel(as);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
204
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
205 % Export data
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
206 for kk=1:Na
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
207 export(as(kk), tmpData{kk}, plist('complex format', 'absdeg'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
208 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
209
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
210 % Process each AO
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
211 for kk=1:Na
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
212
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
213 % Are we processing complex data?
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
214 complexData = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
215 if ~isreal(as(kk).y)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
216 complexData = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
217 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
218
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
219 [path,name,ext] = fileparts(output);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
220 ofile = fullfile(path,sprintf('%s_%02d%s',name,kk,ext));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
221 fnames = [fnames {ofile}];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
222
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
223 % Open and write gnu file
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
224 fd = fopen(tmpGnu, 'w+');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
225 writeHeader(fd, terminal, terminalOpts, ofile);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
226
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
227 % Need two plots for complex data
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
228 if complexData
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
229 fprintf(fd, 'set multiplot layout 2,1\n');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
230 end
|
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 % Line style
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
234 [color, lwidth, style, pointType, pointScale] = lineStyle(kk, as(kk), pl);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
235
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
236 % Axis labels
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
237 fprintf(fd, 'set xlabel "Frequency %s"\n', as(kk).xunits.char);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
238 fprintf(fd, 'set ylabel "Amplitude %s"\n', fixUnits(as(kk).yunits.char));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
239
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
240 % Axis scales
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
241 fprintf(fd, 'set lmargin at screen 0.15\n');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
242 fprintf(fd, 'unset logscale xy\n');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
243 fprintf(fd, 'set logscale x\n');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
244 fprintf(fd, 'set logscale y\n');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
245
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
246 % Preamble
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
247 preamble = pl.find('preamble');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
248 writePreamble(fd, preamble);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
249
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
250 % Write the plot line
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
251 fprintf(fd, 'plot "%s" using 1:2 with %s lt %s lw %d %s %s title "%s"\n', ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
252 tmpData{kk}, style, color, lwidth, pointType, pointScale, as(kk).name);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
253 if complexData
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
254 fprintf(fd, 'set ylabel "Phase [deg]"\n');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
255 fprintf(fd, 'unset logscale xy\n');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
256 fprintf(fd, 'set logscale x\n');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
257 fprintf(fd, 'plot "%s" using 1:3 with %s lt %s lw %d %s %s title "%s"\n', ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
258 tmpData{kk}, style, color, lwidth, pointType, pointScale, as(kk).name);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
259 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
260 fclose(fd);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
261 % Run gnuplot
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
262 runcmd(gnuplotBin, tmpGnu);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
263 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
264
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
265 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
266
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
267 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
268 % Plots all the freq-series AOs on individual plots.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
269 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
270 function fnames = write_stacked_freqseries_plot(terminal, terminalOpts, output, tmpGnu, tmpData, as, pl);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
271
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
272 fnames = {output};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
273
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
274 gnuplotBin = pl.find('gnuplot');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
275 Na = numel(as);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
276
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
277 % Check the yunits
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
278 xlbl = as(1).xunits.char;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
279 ylbl = as(1).yunits.char;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
280 ylbl = fixUnits(ylbl);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
281 for kk=2:Na
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
282 if ~strcmp(ylbl,fixUnits(as(kk).yunits.char))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
283 ylbl = '[mixed]';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
284 break;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
285 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
286 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
287
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
288 % Export data
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
289 allReal = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
290 for kk=1:Na
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
291 export(as(kk), tmpData{kk}, plist('complex format', 'absdeg'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
292 if ~isreal(as(kk).y)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
293 allReal = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
294 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
295 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
296
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
297 % Open and write gnu file
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
298 fd = fopen(tmpGnu, 'w+');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
299
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
300 writeHeader(fd, terminal, terminalOpts, output);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
301
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
302 fprintf(fd, 'set lmargin at screen 0.15\n');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
303 % Axis labels
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
304 fprintf(fd, 'set xlabel "Frequency %s"\n', xlbl);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
305 fprintf(fd, 'set ylabel "Amplitude %s"\n', ylbl);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
306
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
307
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
308 % Need two plots for complex data
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
309 if ~allReal
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
310 fprintf(fd, 'set multiplot\n');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
311 fprintf(fd, 'set size 0.9,0.45\n');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
312 fprintf(fd, 'set origin 0.05,0.5\n');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
313 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
314
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
315 fprintf(fd, 'unset logscale xy\n');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
316 fprintf(fd, 'set logscale x\n');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
317 fprintf(fd, 'set logscale y\n');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
318
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
319 % Preamble
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
320 preamble = pl.find('preamble');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
321 writePreamble(fd, preamble);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
322
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
323 % Process real part of each AO
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
324 fprintf(fd, 'plot\\\n');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
325 for kk=1:Na
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
326
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
327 hasErrors = ~isempty(as(kk).dy);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
328
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
329 % Line style
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
330 [color, lwidth, style, pointType, pointScale] = lineStyle(kk, as(kk), pl);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
331 % Write the plot line
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
332 if hasErrors
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
333 fprintf(fd, ' "%s" using 1:2:4 with %s lt %s lw %d %s %s title "%s"', ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
334 tmpData{kk}, style, color, lwidth, pointType, pointScale, as(kk).name);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
335 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
336 fprintf(fd, ' "%s" using 1:2 with %s lt %s lw %d %s %s title "%s"', ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
337 tmpData{kk}, style, color, lwidth, pointType, pointScale, as(kk).name);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
338 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
339 if kk<Na
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
340 fprintf(fd, ',\\\n');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
341 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
342 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
343
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
344 fprintf(fd, '\n\n');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
345
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
346 % Need two plots for complex data
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
347 if ~allReal
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
348 hasErrors = ~isempty(as(kk).dy);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
349 fprintf(fd, 'set ylabel "Phase [deg]"\n');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
350 fprintf(fd, 'set size 0.9,0.45\n');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
351 fprintf(fd, 'set origin 0.05,0.1\n');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
352
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
353 fprintf(fd, 'unset logscale xy\n');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
354 fprintf(fd, 'set logscale x\n');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
355
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
356 % Preamble
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
357 preamble = pl.find('preamble');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
358 writePreamble(fd, preamble);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
359
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
360 % Process real part of each AO
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
361 fprintf(fd, 'plot\\\n');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
362 for kk=1:Na
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
363 if ~isreal(as(kk).y)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
364 % Line style
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
365 [color, lwidth, style, pointType, pointScale] = lineStyle(kk, as(kk), pl);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
366 % Write the plot line
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
367 if hasErrors
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
368 fprintf(fd, ' "%s" using 1:3:4 with %s lt %s lw %d %s %s title "%s"', ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
369 tmpData{kk}, style, color, lwidth, pointType, pointScale, as(kk).name);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
370 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
371 fprintf(fd, ' "%s" using 1:3 with %s lt %s lw %d %s %s title "%s"', ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
372 tmpData{kk}, style, color, lwidth, pointType, pointScale, as(kk).name);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
373 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
374 if kk<Na
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
375 fprintf(fd, ',\\\n');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
376 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
377 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
378 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
379
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
380 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
381
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
382 fclose(fd);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
383
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
384 % Run gnuplot
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
385 runcmd(gnuplotBin, tmpGnu);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
386
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
387 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
388
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
389
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
390 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
391 % Make time-series plot
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
392
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
393 function fnames = ts_plot(output, terminal, terminalOpts, tmpGnu, tmpData, as, pl)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
394
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
395 switch pl.find('arrangement')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
396 case 'single'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
397 fnames = write_single_timeseries_plot(terminal, terminalOpts, output, tmpGnu, tmpData, as, pl);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
398 case 'stacked'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
399 fnames = write_stacked_timeseries_plot(terminal, terminalOpts, output, tmpGnu, tmpData, as, pl);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
400 case 'subplots'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
401 fnames = write_subplot_timeseries_plot(terminal, terminalOpts, output, tmpGnu, tmpData, as, pl);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
402 otherwise
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
403 fnames = {};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
404 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
405
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
406 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
407
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
408
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
409 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
410 % Plots all time-series AOs on a single x-y plot. If the AOs have different
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
411 % yunits, then the label is set to [mixed].
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
412 function fnames = write_stacked_timeseries_plot(terminal, terminalOpts, output, tmpGnu, tmpData, as, pl)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
413
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
414 fnames = {output};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
415
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
416 gnuplotBin = pl.find('gnuplot');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
417 Na = numel(as);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
418
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
419 % Check the yunits
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
420 xlbl = as(1).xunits.char;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
421 ylbl = as(1).yunits.char;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
422 ylbl = fixUnits(ylbl);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
423 for kk=2:Na
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
424 if ~strcmp(ylbl,fixUnits(as(kk).yunits.char))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
425 ylbl = '[mixed]';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
426 break;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
427 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
428 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
429
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
430 % Export data
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
431 for kk=1:Na
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
432 export(as(kk), tmpData{kk}, plist('complex format', 'absdeg'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
433 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
434
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
435 % Open and write gnu file
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
436 fd = fopen(tmpGnu, 'w+');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
437
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
438 writeHeader(fd, terminal, terminalOpts, output);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
439
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
440 % Axis labels
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
441 fprintf(fd, 'set xlabel "Time %s"\n', xlbl);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
442 fprintf(fd, 'set ylabel "Amplitude %s"\n', ylbl);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
443
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
444 % Preamble
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
445 preamble = pl.find('preamble');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
446 writePreamble(fd, preamble);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
447
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
448 % Process each AO
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
449 fprintf(fd, 'plot\\\n');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
450 for kk=1:Na
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
451 % Line style
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
452 [color, lwidth, style, pointType, pointScale] = lineStyle(kk, as(kk), pl);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
453 % Write the plot line
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
454 fprintf(fd, ' "%s" using 1:2 with %s lt %s lw %d %s %s title "%s"', ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
455 tmpData{kk}, style, color, lwidth, pointType, pointScale, as(kk).name);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
456 if kk<Na
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
457 fprintf(fd, ',\\\n');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
458 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
459 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
460 fclose(fd);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
461
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
462 % Run gnuplot
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
463 runcmd(gnuplotBin, tmpGnu);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
464 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
465
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
466
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
467 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
468 % Plots all time-series AOs on a single x-y plot. If the AOs have different
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
469 % yunits, then the label is set to [mixed].
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
470 function fnames = write_subplot_timeseries_plot(terminal, terminalOpts, output, tmpGnu, tmpData, as, pl)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
471
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
472 fnames = {output};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
473 gnuplotBin = pl.find('gnuplot');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
474 Na = numel(as);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
475
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
476
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
477 % Export data
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
478 for kk=1:Na
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
479 export(as(kk), tmpData{kk}, plist('complex format', 'absdeg'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
480 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
481
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
482 % Open and write gnu file
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
483 fd = fopen(tmpGnu, 'w+');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
484
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
485 writeHeader(fd, terminal, terminalOpts, output);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
486
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
487 fprintf(fd, 'set multiplot layout %d,1\n', Na);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
488
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
489
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
490
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
491 % Process each AO
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
492 for kk=1:Na
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
493 % Line style
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
494 [color, lwidth, style, pointType, pointScale] = lineStyle(kk, as(kk), pl);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
495 % Axis labels
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
496 fprintf(fd, 'set xlabel "Time %s"\n', as(kk).xunits.char);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
497 fprintf(fd, 'set ylabel "Amplitude %s"\n', fixUnits(as(kk).yunits.char));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
498 % Preamble
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
499 preamble = pl.find('preamble');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
500 writePreamble(fd, preamble);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
501 % Write the plot line
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
502 fprintf(fd, 'plot "%s" using 1:2 with %s lt %s lw %d %s %s title "%s"\n', ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
503 tmpData{kk}, style, color, lwidth, pointType, pointScale, as(kk).name);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
504 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
505 fclose(fd);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
506
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
507 % Run gnuplot
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
508 runcmd(gnuplotBin, tmpGnu);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
509 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
510
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
511 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
512 % Plots all time-series AOs on a single x-y plot. If the AOs have different
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
513 % yunits, then the label is set to [mixed].
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
514 function fnames = write_single_timeseries_plot(terminal, terminalOpts, output, tmpGnu, tmpData, as, pl)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
515
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
516 fnames = {};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
517 gnuplotBin = pl.find('gnuplot');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
518 Na = numel(as);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
519
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
520 % Export data
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
521 for kk=1:Na
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
522 export(as(kk), tmpData{kk}, plist('complex format', 'absdeg'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
523 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
524
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
525 % Process each AO
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
526 for kk=1:Na
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
527
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
528 [path,name,ext] = fileparts(output);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
529 ofile = fullfile(path,sprintf('%s_%02d%s',name,kk,ext));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
530 fnames = [fnames {ofile}];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
531
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
532 % Open and write gnu file
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
533 fd = fopen(tmpGnu, 'w+');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
534 writeHeader(fd, terminal, terminalOpts, ofile);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
535
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
536
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
537 % Line style
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
538 [color, lwidth, style, pointType, pointScale] = lineStyle(kk, as(kk), pl);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
539
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
540 % Axis labels
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
541 fprintf(fd, 'set xlabel "Time %s"\n', as(kk).xunits.char);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
542 fprintf(fd, 'set ylabel "Amplitude %s"\n', fixUnits(as(kk).yunits.char));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
543
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
544 % Preamble
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
545 preamble = pl.find('preamble');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
546 writePreamble(fd, preamble);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
547
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
548 % Write the plot line
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
549 fprintf(fd, 'plot "%s" using 1:2 with %s lt %s lw %d %s %s title "%s"\n', ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
550 tmpData{kk}, style, color, lwidth, pointType, pointScale, as(kk).name);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
551 fclose(fd);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
552 % Run gnuplot
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
553 runcmd(gnuplotBin, tmpGnu);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
554 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
555
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
556 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
557
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
558
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
559 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
560 % Functions for writing the GNUPLOT file.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
561 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
562
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
563 function writeHeader(fd, terminal, terminalOpts, output)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
564 fprintf(fd, 'set terminal %s %s \n', terminal, terminalOpts);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
565 if ~isempty(output)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
566 fprintf(fd, 'set output "%s"\n', output);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
567 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
568 fprintf(fd, 'set key outside\n');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
569 fprintf(fd, 'set grid xtics ytics\n');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
570 fprintf(fd, 'set key invert box\n');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
571
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
572 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
573
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
574 function writePreamble(fd, preamble)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
575
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
576 if ischar(preamble)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
577 preamble = {preamble};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
578 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
579 for kk=1:numel(preamble)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
580 fprintf(fd, '%s\n', preamble{kk});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
581 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
582
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
583 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
584
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
585
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
586 function [color, lwidth, style, pointType, pointScale] = lineStyle(kk, as, pl)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
587
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
588 info = as.plotinfo;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
589 if ~isempty(info)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
590 color = info.find('color');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
591 lwidth = info.find('linewidth');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
592 marker = info.find('marker');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
593 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
594 color = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
595 lwidth = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
596 marker = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
597 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
598
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
599 % Color for this ao
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
600 color = mcol2gcol(kk, color);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
601
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
602 % line width
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
603 if isempty(lwidth)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
604 lwidth = 2;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
605 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
606
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
607 % Marker
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
608 [style, pointType] = getMarker(marker, isempty(as.dy));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
609 pointScale = getPointScale(pl.find('markerscale'), pointType);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
610 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
611
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
612 function [style, pointType] = getMarker(marker, noErrors)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
613 if noErrors
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
614 if isempty(marker)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
615 style = 'l';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
616 pointType = '';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
617 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
618 style = 'lp';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
619 pointType = sprintf('pt %d', mmarkerTogmarker(marker));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
620 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
621 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
622 if isempty(marker)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
623 style = 'errorlines';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
624 pointType = '';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
625 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
626 style = 'errorlines';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
627 pointType = sprintf('pt %d', mmarkerTogmarker(marker));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
628 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
629 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
630
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
631 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
632
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
633 function pointScale = getPointScale(size, pointType)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
634
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
635 pointScale = '';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
636 if pointType > 0
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
637 if ~isempty(size)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
638 pointScale = sprintf('ps %d', size);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
639 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
640 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
641
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
642 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
643
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
644
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
645 % Return a gnuplot point type based on the matlab marker.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
646 % This is terminal dependent and so only works in some cases.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
647 function pt = mmarkerTogmarker(mm)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
648
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
649 switch mm
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
650 case '+'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
651 pt = 1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
652 case 'x'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
653 pt = 2;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
654 case 's'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
655 pt = 4;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
656 case 'd'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
657 pt = 5;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
658 case '^'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
659 pt = 6;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
660 otherwise
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
661 pt = 0;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
662 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
663
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
664 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
665
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
666 % Prepare units for gnuplot
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
667 function str = fixUnits(str)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
668
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
669 str = strrep(strrep(str, '(', '{'), ')', '}');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
670
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
671 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
672
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
673
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
674 % Returns an RGB color from a MATLAB string color
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
675 function col = mcol2gcol(kk, mcol)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
676
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
677 if isempty(mcol)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
678 col = num2str(kk);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
679 return
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
680 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
681
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
682 if ischar(mcol)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
683 str = mcol;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
684 switch str
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
685 case 'r'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
686 col = 'red';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
687 case 'g'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
688 col = 'blue';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
689 case 'b'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
690 col = 'blue';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
691 case 'c'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
692 col = 'cyan';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
693 case 'm'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
694 col = 'magenta';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
695 case 'y'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
696 col = 'yellow';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
697 case 'k'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
698 col = 'black';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
699 case 'w'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
700 col = 'white';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
701 otherwise
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
702 col = str;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
703 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
704 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
705
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
706 % If we have a matlab rgb vector, we need to conver to a hex for
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
707 % gnuplot
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
708
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
709 r = dec2hex(round(255*mcol(1)));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
710 g = dec2hex(round(255*mcol(2)));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
711 b = dec2hex(round(255*mcol(3)));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
712
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
713 col = ['#' r g b];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
714
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
715 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
716
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
717 col = sprintf('rgb "%s"', col);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
718
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
719 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
720
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
721
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
722
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
723 %---------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
724 % This will run a shell command from within MATLAB using the given
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
725 % arguments.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
726 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
727 % usage: runcmd(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
728 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
729 % varargin - a series of strings to be concatenated together.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
730 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
731 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
732 % e.g. >> runcmd('ls', '-l', dir);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
733 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
734 % M Hewitson 16-07-04
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
735 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
736 % $Id: gnuplot.m,v 1.12 2011/04/13 04:51:36 mauro Exp $
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
737 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
738 function runcmd(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
739
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
740 fid = fopen('tmpcmd', 'w+');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
741 fprintf(fid, '#!/bin/bash\n');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
742 fprintf(fid, 'export PATH=$PATH:${HOME}/bin\n');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
743 for jj = 1:nargin
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
744 fprintf(fid, '%s ', varargin{jj});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
745 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
746 fprintf(fid, '\n');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
747 fclose(fid);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
748
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
749 !chmod +x tmpcmd
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
750 !./tmpcmd
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
751 !rm tmpcmd
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
752 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
753
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
754 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
755 % Collect the AOs together by data class
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
756 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
757 function [timeAOs, freqAOs, yAOs, xyAOs] = collectAOs(as)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
758
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
759 timeAOs = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
760 freqAOs = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
761 yAOs = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
762 xyAOs = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
763
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
764 for jj = 1:numel(as)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
765
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
766 switch class(as(jj).data)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
767 case 'tsdata'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
768
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
769 timeAOs = [timeAOs as(jj)];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
770
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
771 case 'fsdata'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
772
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
773 freqAOs = [freqAOs as(jj)];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
774
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
775 case 'xydata'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
776
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
777 yAOs = [yAOs as(jj)];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
778
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
779 case 'cdata'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
780
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
781 xyAOs = [xyAOs as(jj)];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
782
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
783 otherwise
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
784 utils.helper.warn('Unsupported AO data type [%s]; skipping', class(as(jj).data));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
785 end % End switch on data type
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
786 end % End loop over AOs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
787
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
788 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
789
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
790
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
791 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
792 % Get Info Object
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
793 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
794 function ii = getInfo(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
795 if nargin == 1 && strcmpi(varargin{1}, 'None')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
796 sets = {};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
797 pl = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
798 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
799 sets = {'Default'};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
800 pl = getDefaultPlist();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
801 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
802 % Build info object
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
803 ii = minfo(mfilename, 'ao', 'ltpda', utils.const.categories.output, '$Id: gnuplot.m,v 1.12 2011/04/13 04:51:36 mauro Exp $', sets, pl);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
804 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
805
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
806 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
807 % Get Default Plist
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
808 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
809 function plout = getDefaultPlist()
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
810 persistent pl;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
811 if ~exist('pl', 'var') || isempty(pl)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
812 pl = buildplist();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
813 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
814 plout = pl;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
815 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
816
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
817 function pl = buildplist()
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
818
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
819 % General plist for Welch-based, linearly spaced spectral estimators
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
820 pl = plist();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
821
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
822 % Binary
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
823 p = param({'gnuplot', ['The path to the gnuplot binary.']},...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
824 paramValue.STRING_VALUE('/opt/local/bin/gnuplot'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
825 pl.append(p);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
826
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
827 % Output dir
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
828 p = param({'OutputDir', ['The output directory to be used in the case of writing output files.']},...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
829 paramValue.STRING_VALUE(''));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
830 pl.append(p);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
831
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
832 % Output file
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
833 p = param({'Output', ['The output filename for the given terminal type.\n'...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
834 'An empty output will result in the output being sent to the terminal.']},...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
835 paramValue.STRING_VALUE(''));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
836 pl.append(p);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
837
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
838 % Terminal type
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
839 p = param({'Terminal', 'Choose one of the gnuplot supported terminal types.'},...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
840 paramValue.STRING_VALUE('pdf'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
841 pl.append(p);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
842
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
843 % Terminal Options
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
844 p = param({'Terminal Options', 'Additional terminal options.'},...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
845 paramValue.STRING_VALUE('color enhanced fsize 14 size 24cm,16cm'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
846 pl.append(p);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
847
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
848 % Preamble
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
849 p = param({'Preamble', 'A cell-array of gnuplot commands which are inserted before the plotting but after the basic commands.'},...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
850 paramValue.EMPTY_CELL);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
851 pl.append(p);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
852
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
853 % Arrangement
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
854 p = param({'Arrangement', ['Chose how to plot multiple AOs:\n'...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
855 '<ul><li> on one plot (stacked)</li><li>on separate plots (single)</li>'...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
856 '<li>on subplots (subplots) </li></ul><br>In the case of ''single'', if you use an<br>'...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
857 'output file, then each file will be appended with a number, e.g., foo_1.pdf, foo_2.pdf.']},...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
858 {1, {'stacked', 'single', 'subplots'}, paramValue.SINGLE});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
859 pl.append(p);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
860
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
861 % Marker scale
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
862 p = param({'MarkerScale', ['Scale the size of the markers by an integer amount.']},...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
863 paramValue.DOUBLE_VALUE(1));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
864 pl.append(p);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
865
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
866
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
867 end
|