0001 function varargout = iplot(varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100 VERSION = '$Id: iplot.m,v 1.17 2008/01/21 11:40:25 hewitson Exp $';
0101 bs = [];
0102
0103 if nargin == 2
0104 if isa(varargin{1}, 'ao') && ischar(varargin{2})
0105 in = char(varargin{2});
0106 if strcmp(in, 'Params')
0107 varargout{1} = getDefaultPlist();
0108 return
0109 elseif strcmp(in, 'Version')
0110 varargout{1} = VERSION;
0111 return
0112 end
0113 end
0114 end
0115
0116
0117 in_names = {};
0118 for ii = 1:nargin
0119 in_names{end+1} = inputname(ii);
0120 end
0121
0122 [as, upl, invars] = collect_inputs(varargin, in_names);
0123
0124
0125
0126 tsAOs = [];
0127 fsAOs = [];
0128 xyAOs = [];
0129 xyzAOs = [];
0130 cAOs = [];
0131
0132 for j=1:numel(as)
0133 switch class(as(j).data)
0134 case 'tsdata'
0135 tsAOs = [tsAOs as(j)];
0136 case 'fsdata'
0137 fsAOs = [fsAOs as(j)];
0138 case 'xydata'
0139 xyAOs = [xyAOs as(j)];
0140 case 'xyzdata'
0141 xyzAOs = [xyzAOs as(j)];
0142 case 'cdata'
0143 cAOs = [cAOs as(j)];
0144 otherwise
0145 warning('!!! Unknown data type %s', class(as(j).data));
0146 end
0147 end
0148
0149
0150
0151 hfig = [];
0152 hax = [];
0153 hli = [];
0154
0155
0156
0157
0158 dpl = getDefaultPlist('tsdata');
0159
0160 pl = combine(upl, dpl);
0161
0162 [hf, ha, hl] = xy_plot(tsAOs, pl);
0163 hfig = [hfig hf];
0164 hax = [hax ha];
0165 hli = [hli hl];
0166
0167
0168
0169
0170 dpl = getDefaultPlist('xydata');
0171
0172 pl = combine(upl, dpl);
0173
0174 [hf, ha, hl] = xy_plot(xyAOs, pl);
0175 hfig = [hfig hf];
0176 hax = [hax ha];
0177 hli = [hli hl];
0178
0179
0180
0181
0182 dpl = getDefaultPlist('xyzdata');
0183
0184 pl = combine(upl, dpl);
0185
0186 [hf, ha, hl] = xyz_plot(xyzAOs, pl);
0187 hfig = [hfig hf];
0188 hax = [hax ha];
0189 hli = [hli hl];
0190
0191
0192
0193
0194 dpl = getDefaultPlist('cdata');
0195
0196 pl = combine(upl, dpl);
0197
0198 [hf, ha, hl] = y_plot(cAOs, pl);
0199 hfig = [hfig hf];
0200 hax = [hax ha];
0201 hli = [hli hl];
0202
0203
0204
0205
0206 dpl = getDefaultPlist('fsdata');
0207
0208 pl = combine(upl, dpl);
0209
0210 [hf, ha, hl] = fs_plot(fsAOs, pl);
0211 hfig = [hfig hf];
0212 hax = [hax ha];
0213 hli = [hli hl];
0214
0215
0216 if nargout == 1
0217 varargout{1} = hfig;
0218 end
0219 if nargout == 2
0220 varargout{1} = hfig;
0221 varargout{2} = hax;
0222 end
0223 if nargout == 3
0224 varargout{1} = hfig;
0225 varargout{2} = hax;
0226 varargout{3} = hli;
0227 end
0228
0229 if nargout > 3
0230 error('### Incorrect number of outputs');
0231 end
0232
0233
0234
0235
0236
0237 function varargout = fs_plot(varargin)
0238
0239 aos = varargin{1};
0240 pl = varargin{2};
0241
0242
0243 arrangement = find(pl, 'Arrangement');
0244 linecolors = find(pl, 'LineColors');
0245 colors = find(pl, 'Colors');
0246 linestyles = find(pl, 'LineStyles');
0247 markers = find(pl, 'Markers');
0248 linewidths = find(pl, 'LineWidths');
0249 legends = find(pl, 'Legends');
0250 ylabels = find(pl, 'YLabels');
0251 xlabels = find(pl, 'XLabels');
0252 yscales = find(pl, 'YScales');
0253 xscales = find(pl, 'XScales');
0254 yranges = find(pl, 'YRanges');
0255 xranges = find(pl, 'XRanges');
0256 xmaths = find(pl, 'XMaths');
0257 ymaths = find(pl, 'YMaths');
0258 complexPlotType = find(pl, 'complexPlotType');
0259
0260
0261 if iscell(legends)
0262 legendsOn = 1;
0263 else
0264 if strcmpi(legends, 'off')
0265 legendsOn = 0;
0266 else
0267 legendsOn = 1;
0268 legends = [];
0269 end
0270 end
0271
0272 if ~iscell(linestyles), linestyles = {linestyles}; end
0273 if ~iscell(linecolors), linecolors = {linecolors}; end
0274 if ~iscell(markers), markers = {markers}; end
0275 if ~iscell(legends), legends = {legends}; end
0276 if ~iscell(ylabels), ylabels = {ylabels}; end
0277 if ~iscell(xlabels), xlabels = {xlabels}; end
0278 if ~iscell(xmaths), xmaths = {xmaths}; end
0279 if ~iscell(ymaths), ymaths = {ymaths}; end
0280 if ~iscell(xscales), xscales = {xscales}; end
0281 if ~iscell(yscales), yscales = {yscales}; end
0282 if ~iscell(xranges), xranges = {xranges}; end
0283 if ~iscell(yranges), yranges = {yranges}; end
0284
0285
0286
0287 tsfig = [];
0288 tsax = [];
0289 tsli = [];
0290
0291
0292 legendStr = [];
0293
0294 if ~isempty(aos)
0295
0296
0297 Na = length(aos);
0298
0299
0300 haveComplex = 0;
0301 for j=1:Na
0302 a = aos(j);
0303 y = a.data.y;
0304 ymath = '';
0305 if j<=length(ymaths)
0306 if ~isempty(ymaths{j})
0307 eval(sprintf('y = %s;', ymaths{j}));
0308 ymath = ymaths{j};
0309 end
0310 end
0311 xmath = '';
0312 if j<=length(xmaths)
0313 if ~isempty(xmaths{j})
0314 eval(sprintf('x = %s;', xmaths{j}));
0315 xmath = xmaths{j};
0316 end
0317 end
0318 if ~isreal(y)
0319 haveComplex = 1;
0320 end
0321 end
0322
0323
0324 for j=1:Na
0325
0326
0327 tsax_r = [];
0328 tsax_i = [];
0329
0330
0331 a = aos(j);
0332
0333
0334 x = a.data.x;
0335 y = a.data.y;
0336
0337 ymath = '';
0338 if j<=length(ymaths)
0339 if ~isempty(ymaths{j})
0340 eval(sprintf('y = %s;', ymaths{j}));
0341 ymath = ymaths{j};
0342 end
0343 end
0344 xmath = '';
0345 if j<=length(xmaths)
0346 if ~isempty(xmaths{j})
0347 eval(sprintf('x = %s;', xmaths{j}));
0348 xmath = xmaths{j};
0349 end
0350 end
0351
0352
0353 switch arrangement
0354 case 'single'
0355
0356 tsfig = [tsfig figure];
0357 col = colors{1};
0358
0359 if ~isreal(y)
0360
0361 tsax_r = subplot(2,1,1);
0362 tsax_i = subplot(2,1,2);
0363 tsax = [tsax tsax_r tsax_i];
0364 else
0365
0366 tsax_r = subplot(1, 1, 1);
0367 tsax = [tsax tsax_r];
0368 end
0369
0370 case 'stacked'
0371
0372 if j==1, tsfig = figure; end
0373
0374
0375 if haveComplex
0376 tsax_r = subplot(2,1,1);
0377 tsax_i = subplot(2,1,2);
0378 tsax = [tsax_r tsax_i];
0379 else
0380 tsax_r = subplot(1, 1, 1);
0381 tsax = tsax_r;
0382 end
0383 col = colors{mod(j-1,length(colors))+1};
0384 hold(tsax_r, 'on');
0385 if ishandle(tsax_i)
0386 hold(tsax_i, 'on');
0387 end
0388 case 'subplots'
0389
0390 if j == 1, tsfig = figure; end
0391 c = 1+(j-1)*2;
0392 sx = Na;
0393 sy = 2;
0394
0395 if ~isreal(y)
0396 tsax_r = subplot(sx, sy,c);
0397 tsax_i = subplot(sx, sy,c+1);
0398 tsax = [tsax tsax_r tsax_i];
0399 else
0400 tsax_r = subplot(sx, sy, c:c+1);
0401 tsax = [tsax tsax_r];
0402 end
0403 col = colors{1};
0404
0405 otherwise
0406 error('### Unknown plot arrangement');
0407 end
0408
0409
0410
0411
0412
0413 if isreal(y)
0414 tsli = [tsli plot(tsax_r, x, y)];
0415 ylabelr = 'amplitude';
0416 ylabeli = 'imag';
0417 yscaleR = 'log';
0418 yscaleI = 'lin';
0419 xscaleR = 'log';
0420 xscaleI = 'lin';
0421 else
0422 switch complexPlotType
0423 case 'realimag'
0424 tsli = [tsli plot(tsax_r, x, real(y))];
0425 tsli = [tsli plot(tsax_i, x, imag(y))];
0426 ylabelr = 'real';
0427 ylabeli = 'imag';
0428 yscaleR = 'lin';
0429 yscaleI = 'lin';
0430 xscaleR = 'lin';
0431 xscaleI = 'lin';
0432 case 'absdeg'
0433 tsli = [tsli plot(tsax_r, x, abs(y))];
0434 tsli = [tsli plot(tsax_i, x, ltpda_phase(y))];
0435 ylabelr = 'amplitude';
0436 ylabeli = 'Phase [deg]';
0437 yscaleR = 'log';
0438 yscaleI = 'lin';
0439 xscaleR = 'log';
0440 xscaleI = 'log';
0441 case 'absrad'
0442 tsli = [tsli plot(tsax_r, x, abs(y))];
0443 tsli = [tsli plot(tsax_i, x, angle(y))];
0444 ylabelr = 'amplitude';
0445 ylabeli = 'phase [rad]';
0446 yscaleR = 'log';
0447 yscaleI = 'lin';
0448 xscaleR = 'log';
0449 xscaleI = 'log';
0450 otherwise
0451 error('### Unknown plot type for complex data');
0452 end
0453 end
0454
0455
0456
0457
0458 c = 1+(j-1)*2;
0459 if c<=length(ylabels)
0460 if ~isempty(ylabels{c})
0461 ylstrR = ylabels{c};
0462 else
0463 ylstrR = ylabelr;
0464 end
0465 else
0466 ylstrR = ylabelr;
0467 end
0468 if c<length(ylabels)
0469 if ~isempty(ylabels{c+1})
0470 ylstrI = ylabels{c+1};
0471 else
0472 ylstrI = ylabeli;
0473 end
0474 else
0475 ylstrI = ylabeli;
0476 end
0477 if ~isempty(ymath)
0478 ymath = strrep(ymath, 'y', sprintf('%s', a.data.yunits));
0479 ylstrR = [ylstrR ' [' ymath ']' ];
0480 else
0481 ylstrR = [ylstrR ' [' a.data.yunits ']' ];
0482 end
0483 ylabel(tsax_r, ylstrR);
0484 if ishandle(tsax_i)
0485 ylabel(tsax_i, ylstrI);
0486 end
0487
0488
0489 if j<=length(xlabels) && ~isempty(xlabels{j})
0490 xlstr = xlabels{j};
0491 else
0492 xlstr = find(pl, 'XLabel');
0493 end
0494 if ~isempty(xmath)
0495 xmath = strrep(xmath, 'x', sprintf('%s', a.data.xunits));
0496 xlstr = [xlstr ' [' xmath ']' ];
0497 else
0498 xlstr = [xlstr ' [' a.data.xunits ']' ];
0499 end
0500 xlabel(tsax_r, xlstr);
0501 if ishandle(tsax_i)
0502 xlabel(tsax_i, xlstr);
0503 end
0504
0505
0506 grid(tsax_r, 'on');
0507 if ishandle(tsax_i)
0508 grid(tsax_i, 'on');
0509 end
0510
0511
0512 c = 1+(j-1)*2;
0513 if c<=length(yscales)
0514 if ~isempty(yscales{c})
0515 yscaleR = yscales{c};
0516 end
0517 end
0518 if c<length(yscales)
0519 if ~isempty(yscales{c+1})
0520 yscaleI = yscales{c+1};
0521 end
0522 end
0523 set(tsax_r, 'YScale', yscaleR);
0524 if ishandle(tsax_i)
0525 set(tsax_i, 'YScale', yscaleI);
0526 end
0527
0528
0529 c = 1+(j-1)*2;
0530 if c<=length(xscales)
0531 if ~isempty(xscales{c})
0532 xscaleR = xscales{c};
0533 end
0534 end
0535 if c<length(xscales)
0536 if ~isempty(xscales{c+1})
0537 xscaleI = xscales{c+1};
0538 end
0539 end
0540 set(tsax_r, 'XScale', xscaleR);
0541 if ishandle(tsax_i)
0542 set(tsax_i, 'XScale', xscaleI);
0543 end
0544
0545
0546 c = 1+(j-1)*2;
0547 if c<=length(yranges)
0548 if ~isempty(yranges{c})
0549 set(tsax_r, 'YLim', yranges{c});
0550 end
0551 end
0552 if c<length(yranges)
0553 if ~isempty(yranges{c+1})
0554 if ishandle(tsax_i)
0555 set(tsax_i, 'YLim', yranges{c+1});
0556 end
0557 end
0558 end
0559
0560
0561 c = 1+(j-1)*2;
0562 if c<=length(xranges)
0563 if ~isempty(xranges{c})
0564 set(tsax_r, 'XLim', xranges{c});
0565 end
0566 end
0567 if c<length(xranges)
0568 if ~isempty(xranges{c+1})
0569 if ishandle(tsax_i)
0570 set(tsax_i, 'XLim', xranges{c+1});
0571 end
0572 end
0573 end
0574
0575
0576
0577
0578 if isreal(y)
0579 set(tsli(end), 'Color', col);
0580 else
0581 set(tsli(end-1), 'Color', col);
0582 set(tsli(end), 'Color', col);
0583 end
0584
0585
0586 if j<=length(linecolors) && ~isempty(linecolors{j})
0587 if isreal(y)
0588 set(tsli(end), 'Color', linecolors{j});
0589 else
0590 set(tsli(end-1), 'Color', linecolors{j});
0591 set(tsli(end), 'Color', linecolors{j});
0592 end
0593 end
0594
0595
0596 if j<=length(linestyles) && ~isempty(linestyles{j})
0597 if isreal(y)
0598 set(tsli(end), 'LineStyle', linestyles{j});
0599 else
0600 set(tsli(end-1), 'LineStyle', linestyles{j});
0601 set(tsli(end), 'LineStyle', linestyles{j});
0602 end
0603 end
0604
0605
0606 if j<=length(linewidths) && ~isempty(linewidths(j))
0607 if isreal(y)
0608 set(tsli(end), 'LineWidth', linewidths(j));
0609 else
0610 set(tsli(end-1), 'LineWidth', linewidths(j));
0611 set(tsli(end), 'LineWidth', linewidths(j));
0612 end
0613 end
0614
0615
0616 if j<=length(markers) && ~isempty(markers{j})
0617 if isreal(y)
0618 set(tsli(end), 'Marker', markers{j});
0619 else
0620 set(tsli(end-1), 'Marker', markers{j});
0621 set(tsli(end), 'Marker', markers{j});
0622 end
0623 end
0624
0625
0626
0627 lstr = '';
0628 if legendsOn
0629 if j<=length(legends) && ~isempty(legends{j})
0630 lstr = legends{j};
0631 else
0632 lstr = ltpda_label(a.name);
0633 end
0634 end
0635 legendStr = [legendStr cellstr(lstr)];
0636
0637
0638 if legendsOn
0639 if strcmp(arrangement, 'single') || strcmp(arrangement, 'subplots')
0640 legend(tsax_r, legendStr{end});
0641 end
0642 end
0643
0644 end
0645
0646
0647 if legendsOn
0648 if strcmp(arrangement, 'stacked')
0649 h = legend(tsax_r, legendStr);
0650 set(h, 'FontSize', 10)
0651 end
0652 end
0653
0654 end
0655
0656
0657 if nargout > 0
0658 varargout{1} = tsfig;
0659 end
0660 if nargout > 1
0661 varargout{2} = tsax;
0662 end
0663 if nargout == 3
0664 varargout{3} = tsli;
0665 end
0666 if nargout > 3
0667 error('### Too many output arguments');
0668 end
0669
0670
0671
0672
0673 function varargout = xy_plot(varargin)
0674
0675 aos = varargin{1};
0676 pl = varargin{2};
0677
0678
0679 arrangement = find(pl, 'Arrangement');
0680 linecolors = find(pl, 'LineColors');
0681 colors = find(pl, 'Colors');
0682 linestyles = find(pl, 'LineStyles');
0683 markers = find(pl, 'Markers');
0684 linewidths = find(pl, 'LineWidths');
0685 legends = find(pl, 'Legends');
0686 ylabels = find(pl, 'YLabels');
0687 xlabels = find(pl, 'XLabels');
0688 xmaths = find(pl, 'XMaths');
0689 ymaths = find(pl, 'YMaths');
0690
0691
0692 if iscell(legends)
0693 legendsOn = 1;
0694 else
0695 if strcmpi(legends, 'off')
0696 legendsOn = 0;
0697 else
0698 legendsOn = 1;
0699 legends = [];
0700 end
0701 end
0702
0703 if ~iscell(linestyles), linestyles = {linestyles}; end
0704 if ~iscell(linecolors), linecolors = {linecolors}; end
0705 if ~iscell(markers), markers = {markers}; end
0706 if ~iscell(legends), legends = {legends}; end
0707 if ~iscell(ylabels), ylabels = {ylabels}; end
0708 if ~iscell(xlabels), xlabels = {xlabels}; end
0709 if ~iscell(xmaths), xmaths = {xmaths}; end
0710 if ~iscell(ymaths), ymaths = {ymaths}; end
0711
0712
0713
0714 tsfig = [];
0715 tsax = [];
0716 tsli = [];
0717
0718
0719 legendStr = [];
0720
0721 if ~isempty(aos)
0722
0723
0724 Na = length(aos);
0725 for j=1:Na
0726
0727
0728 a = aos(j);
0729
0730
0731 switch arrangement
0732 case 'single'
0733
0734 tsfig = [tsfig figure];
0735 tsax = subplot(1,1,1);
0736 col = colors{1};
0737
0738 case 'stacked'
0739
0740 if j==1, tsfig = figure; end
0741 tsax = subplot(1,1,1);
0742 col = colors{mod(j-1,length(colors))+1};
0743 hold on;
0744
0745 case 'subplots'
0746
0747 if j == 1, tsfig = figure; end
0748 tsax = [tsax subplot(Na, 1, j)];
0749 col = colors{1};
0750
0751 otherwise
0752 error('### Unknown plot arrangement');
0753 end
0754
0755
0756 x = a.data.x;
0757 y = a.data.y;
0758
0759 ymath = '';
0760 if j<=length(ymaths)
0761 if ~isempty(ymaths{j})
0762 eval(sprintf('y = %s;', ymaths{j}));
0763 ymath = ymaths{j};
0764 end
0765 end
0766 xmath = '';
0767 if j<=length(xmaths)
0768 if ~isempty(xmaths{j})
0769 eval(sprintf('x = %s;', xmaths{j}));
0770 xmath = xmaths{j};
0771 end
0772 end
0773
0774
0775
0776 tsli = [tsli plot(tsax(end), x, y)];
0777
0778
0779
0780
0781 if j<=length(ylabels) && ~isempty(ylabels{j})
0782 ylstr = ylabels{j};
0783 else
0784 ylstr = find(pl, 'YLabel');
0785 end
0786 if ~isempty(ymath)
0787 ymath = strrep(ymath, 'y', sprintf('%s', a.data.yunits));
0788 ylstr = [ylstr ' [' ymath ']' ];
0789 else
0790 ylstr = [ylstr ' [' a.data.yunits ']' ];
0791 end
0792 ylabel(ylstr);
0793
0794
0795 if j<=length(xlabels) && ~isempty(xlabels{j})
0796 xlstr = xlabels{j};
0797 else
0798 xlstr = find(pl, 'XLabel');
0799 end
0800 if ~isempty(xmath)
0801 xmath = strrep(xmath, 'x', sprintf('%s', a.data.xunits));
0802 xlstr = [xlstr ' [' xmath ']' ];
0803 else
0804 xlstr = [xlstr ' [' a.data.xunits ']' ];
0805 end
0806 xlabel(xlstr);
0807
0808
0809
0810 grid(tsax(end), 'on');
0811
0812
0813
0814
0815 set(tsli(end), 'Color', col);
0816
0817
0818 if j<=length(linecolors) && ~isempty(linecolors{j})
0819 set(tsli(end), 'Color', linecolors{j});
0820 end
0821
0822
0823 if j<=length(linestyles) && ~isempty(linestyles{j})
0824 set(tsli(end), 'LineStyle', linestyles{j});
0825 end
0826
0827 if j<=length(markers) && ~isempty(markers{j})
0828 set(tsli(end), 'Marker', markers{j});
0829 end
0830
0831
0832 if j<=length(linewidths) && ~isempty(linewidths(j))
0833 set(tsli(end), 'LineWidth', linewidths(j));
0834 end
0835
0836
0837 lstr = '';
0838 if legendsOn
0839 if j<=length(legends) && ~isempty(legends{j})
0840 lstr = legends{j};
0841 else
0842 lstr = ltpda_label(a.name);
0843 end
0844 end
0845 legendStr = [legendStr cellstr(lstr)];
0846
0847
0848 if legendsOn
0849 if strcmp(arrangement, 'single') || strcmp(arrangement, 'subplots')
0850 legend(legendStr{end});
0851 end
0852 end
0853 end
0854
0855
0856 if legendsOn
0857 if strcmp(arrangement, 'stacked')
0858 h = legend(legendStr);
0859 set(h, 'FontSize', 10)
0860 end
0861 end
0862
0863 end
0864
0865
0866 if nargout > 0
0867 varargout{1} = tsfig;
0868 end
0869 if nargout > 1
0870 varargout{2} = tsax;
0871 end
0872 if nargout == 3
0873 varargout{3} = tsli;
0874 end
0875 if nargout > 3
0876 error('### Too many output arguments');
0877 end
0878
0879
0880
0881
0882
0883 function varargout = y_plot(varargin)
0884
0885 aos = varargin{1};
0886 pl = varargin{2};
0887
0888
0889 arrangement = find(pl, 'Arrangement');
0890 linecolors = find(pl, 'LineColors');
0891 colors = find(pl, 'Colors');
0892 linestyles = find(pl, 'LineStyles');
0893 markers = find(pl, 'Markers');
0894 linewidths = find(pl, 'LineWidths');
0895 legends = find(pl, 'Legends');
0896 ylabels = find(pl, 'YLabels');
0897 xlabels = find(pl, 'XLabels');
0898 xmaths = find(pl, 'XMaths');
0899 ymaths = find(pl, 'YMaths');
0900
0901
0902 if iscell(legends)
0903 legendsOn = 1;
0904 else
0905 if strcmp(legends, 'off')
0906 legendsOn = 0;
0907 else
0908 legendsOn = 1;
0909 legends = [];
0910 end
0911 end
0912
0913 if ~iscell(linestyles), linestyles = {linestyles}; end
0914 if ~iscell(linecolors), linecolors = {linecolors}; end
0915 if ~iscell(markers), markers = {markers}; end
0916 if ~iscell(legends), legends = {legends}; end
0917 if ~iscell(ylabels), ylabels = {ylabels}; end
0918 if ~iscell(xlabels), xlabels = {xlabels}; end
0919 if ~iscell(xmaths), xmaths = {xmaths}; end
0920 if ~iscell(ymaths), ymaths = {ymaths}; end
0921
0922
0923 tsfig = [];
0924 tsax = [];
0925 tsli = [];
0926
0927
0928 legendStr = [];
0929
0930 if ~isempty(aos)
0931
0932
0933 Na = length(aos);
0934 for j=1:Na
0935
0936
0937 a = aos(j);
0938
0939
0940 switch arrangement
0941 case 'single'
0942
0943 tsfig = [tsfig figure];
0944 tsax = subplot(1,1,1);
0945 col = colors{1};
0946
0947 case 'stacked'
0948
0949 if j==1, tsfig = figure; end
0950 tsax = subplot(1,1,1);
0951 col = colors{mod(j-1,length(colors))+1};
0952 hold on;
0953
0954 case 'subplots'
0955
0956 if j == 1, tsfig = figure; end
0957 tsax = [tsax subplot(Na, 1, j)];
0958 col = colors{1};
0959
0960 otherwise
0961 error('### Unknown plot arrangement');
0962 end
0963
0964
0965 x = 1:length(a.data.y);
0966 y = a.data.y;
0967
0968 ymath = '';
0969 if j<=length(ymaths)
0970 if ~isempty(ymaths{j})
0971 eval(sprintf('y = %s;', ymaths{j}));
0972 ymath = ymaths{j};
0973 end
0974 end
0975 xmath = '';
0976 if j<=length(xmaths)
0977 if ~isempty(xmaths{j})
0978 eval(sprintf('x = %s;', xmaths{j}));
0979 xmath = xmaths{j};
0980 end
0981 end
0982
0983
0984
0985 idcs = plot(tsax(end), x, y);
0986 tsli = [tsli idcs(1:end).'];
0987
0988
0989
0990
0991 if j<=length(ylabels) && ~isempty(ylabels{j})
0992 ylstr = ylabels{j};
0993 else
0994 ylstr = find(pl, 'YLabel');
0995 end
0996 if ~isempty(ymath)
0997 ymath = strrep(ymath, 'y', sprintf('%s', a.data.yunits));
0998 ylstr = [ylstr ' [' ymath ']' ];
0999 else
1000 ylstr = [ylstr ' [' a.data.yunits ']' ];
1001 end
1002 ylabel(ylstr);
1003
1004
1005 if j<=length(xlabels) && ~isempty(xlabels{j})
1006 xlstr = xlabels{j};
1007 else
1008 xlstr = find(pl, 'XLabel');
1009 end
1010 if ~isempty(xmath)
1011 xmath = strrep(xmath, 'x', sprintf('%s', a.data.xunits));
1012 xlstr = [xlstr ' [' xmath ']' ];
1013 else
1014 xlstr = [xlstr ' [' a.data.xunits ']' ];
1015 end
1016 xlabel(xlstr);
1017
1018
1019
1020 grid(tsax(end), 'on');
1021
1022
1023
1024
1025 set(tsli(end), 'Color', col);
1026
1027
1028 if j<=length(linecolors) && ~isempty(linecolors{j})
1029 set(tsli(end), 'Color', linecolors{j});
1030 end
1031
1032
1033 if j<=length(linestyles) && ~isempty(linestyles{j})
1034 set(tsli(end), 'LineStyle', linestyles{j});
1035 end
1036
1037
1038 if j<=length(markers) && ~isempty(markers{j})
1039 set(tsli(end), 'Marker', markers{j});
1040 end
1041
1042
1043 if j<=length(linewidths)
1044 set(tsli(end), 'LineWidth', linewidths(j));
1045 end
1046
1047
1048 if legendsOn
1049 if j<=length(legends) && ~isempty(legends{j})
1050 legendStr = [legendStr legends(j)];
1051 else
1052 lstr = ltpda_label(a.name);
1053 legendStr = [legendStr cellstr(lstr)];
1054 end
1055 end
1056
1057
1058 if legendsOn
1059 if strcmp(arrangement, 'single') || strcmp(arrangement, 'subplots')
1060 legend(legendStr{end});
1061 end
1062 end
1063 end
1064
1065
1066 if legendsOn
1067 if strcmp(arrangement, 'stacked')
1068 h = legend(legendStr);
1069 set(h, 'FontSize', 10)
1070 end
1071 end
1072
1073 end
1074
1075
1076 if nargout > 0
1077 varargout{1} = tsfig;
1078 end
1079 if nargout > 1
1080 varargout{2} = tsax;
1081 end
1082 if nargout == 3
1083 varargout{3} = tsli;
1084 end
1085 if nargout > 3
1086 error('### Too many output arguments');
1087 end
1088
1089
1090
1091
1092 function varargout = xyz_plot(varargin)
1093
1094 aos = varargin{1};
1095 pl = varargin{2};
1096
1097
1098 arrangement = find(pl, 'Arrangement');
1099 linecolors = find(pl, 'LineColors');
1100 colors = find(pl, 'Colors');
1101 linestyles = find(pl, 'LineStyles');
1102 linewidths = find(pl, 'LineWidths');
1103 legends = find(pl, 'Legends');
1104 zlabels = find(pl, 'ZLabels');
1105 ylabels = find(pl, 'YLabels');
1106 xlabels = find(pl, 'XLabels');
1107 xmaths = find(pl, 'XMaths');
1108 ymaths = find(pl, 'YMaths');
1109 zmaths = find(pl, 'ZMaths');
1110
1111
1112 if iscell(legends)
1113 legendsOn = 1;
1114 else
1115 if strcmp(legends, 'off')
1116 legendsOn = 0;
1117 else
1118 legendsOn = 1;
1119 legends = [];
1120 end
1121 end
1122
1123
1124 tsfig = [];
1125 tsax = [];
1126 tsli = [];
1127
1128
1129 legendStr = [];
1130
1131 if ~isempty(aos)
1132
1133
1134 Na = length(aos);
1135 for j=1:Na
1136
1137
1138 a = aos(j);
1139
1140
1141 switch arrangement
1142 case 'single'
1143
1144 tsfig = [tsfig figure];
1145 tsax = subplot(1,1,1);
1146
1147 case 'subplots'
1148
1149 if j == 1, tsfig = figure; end
1150 tsax = [tsax subplot(Na, 1, j)];
1151
1152 otherwise
1153 error('### Unknown plot arrangement');
1154 end
1155
1156
1157 x = a.data.x;
1158 y = a.data.y;
1159 z = a.data.z;
1160
1161
1162 ymath = '';
1163 if j<=length(ymaths)
1164 if ~isempty(ymaths{j})
1165 eval(sprintf('y = %s;', ymaths{j}));
1166 ymath = ymaths{j};
1167 end
1168 end
1169 xmath = '';
1170 if j<=length(xmaths)
1171 if ~isempty(xmaths{j})
1172 eval(sprintf('x = %s;', xmaths{j}));
1173 xmath = xmaths{j};
1174 end
1175 end
1176 zmath = '';
1177 if j<=length(zmaths)
1178 if ~isempty(zmaths{j})
1179 eval(sprintf('z = %s;', zmaths{j}));
1180 zmath = zmaths{j};
1181 end
1182 end
1183
1184
1185
1186 idcs = pcolor(x,y,z);
1187 tsli = [tsli idcs(1:end).'];
1188
1189
1190 set(idcs, 'EdgeColor', 'none');
1191
1192
1193
1194
1195 set(tsax(end), 'YDir', 'reverse');
1196
1197
1198 if j<=length(ylabels) && ~isempty(ylabels{j})
1199 ylstr = ylabels{j};
1200 else
1201 ylstr = find(pl, 'YLabel');
1202 end
1203 if ~isempty(ymath)
1204 ymath = strrep(ymath, 'y', sprintf('%s', a.data.yunits));
1205 ylstr = [ylstr ' [' ymath ']' ];
1206 else
1207 ylstr = [ylstr ' [' a.data.yunits ']' ];
1208 end
1209 ylabel(ylstr);
1210
1211
1212 if j<=length(xlabels) && ~isempty(xlabels{j})
1213 xlstr = xlabels{j};
1214 else
1215 xlstr = find(pl, 'XLabel');
1216 end
1217 if ~isempty(xmath)
1218 xmath = strrep(xmath, 'x', sprintf('%s', a.data.xunits));
1219 xlstr = [xlstr ' [' xmath ']' ];
1220 else
1221 xlstr = [xlstr ' [' a.data.xunits ']' ];
1222 end
1223 xlabel(xlstr);
1224
1225
1226 grid(tsax(end), 'on');
1227
1228
1229 if ~strcmpi(legends, 'off')
1230 if j<=length(legends) && ~isempty(legends{j})
1231 legendStr = [legendStr legends(j)];
1232 else
1233 lstr = ltpda_label(a.name);
1234 legendStr = [legendStr cellstr(lstr)];
1235 end
1236 end
1237
1238
1239 tstr = legendStr{end};
1240 if legendsOn
1241 title(tstr);
1242 end
1243
1244
1245 hc = colorbar('peer', tsax(end));
1246 if j<=length(zlabels)
1247 if ~isempty(zlabels{j})
1248 zlstr = zlabels{j};
1249 end
1250 else
1251 zlstr = find(pl, 'Zlabel');
1252 end
1253 if ~isempty(zmath), zlstr = [zlstr sprintf('\n%s', zmath)]; end
1254 ylh = get(hc, 'YLabel');
1255 set(ylh, 'String', zlstr);
1256 set(ylh, 'Fontsize', get(tsax(end), 'Fontsize'))
1257 set(ylh, 'FontName', get(tsax(end), 'FontName'))
1258 set(ylh, 'FontAngle', get(tsax(end), 'FontAngle'))
1259 set(ylh, 'FontWeight', get(tsax(end), 'FontWeight'))
1260 end
1261 end
1262
1263
1264 if nargout > 0
1265 varargout{1} = tsfig;
1266 end
1267 if nargout > 1
1268 varargout{2} = tsax;
1269 end
1270 if nargout == 3
1271 varargout{3} = tsli;
1272 end
1273 if nargout > 3
1274 error('### Too many output arguments');
1275 end
1276
1277
1278
1279
1280
1281 function out = getDefaultPlist(varargin)
1282
1283
1284 sets = {'tsdata', 'fsdata', 'cdata', 'xydata'};
1285
1286
1287 colors = getappdata(0,'ltpda_default_plot_colors');
1288
1289 if nargin == 0
1290 out = sets;
1291 return
1292 end
1293
1294 set = varargin{1};
1295
1296 out = plist('Colors', colors, ...
1297 'Arrangement', 'stacked');
1298
1299 switch set
1300 case 'fsdata'
1301 out = append(out, 'type', 'fsdata', ...
1302 'complexPlotType', 'absdeg', ...
1303 'XLabel', 'Frequency');
1304 case 'tsdata'
1305 out = append(out, 'type', 'tsdata', ...
1306 'Xlabel', 'Time', ...
1307 'Ylabel', 'Amplitude');
1308 case 'xydata'
1309 out = append(out, 'type', 'xydata', ...
1310 'Xlabel', 'X-data', ...
1311 'Ylabel', 'Y-data', ...
1312 'YMaths', '', ...
1313 'XMaths', '');
1314 case 'xyzdata'
1315 out = plist('Colors', colors, 'Arrangement', 'single', ...
1316 'type', 'xydata', ...
1317 'Xlabel', 'Time', ...
1318 'Ylabel', 'Frequency',...
1319 'Zlabel', 'Amplitude', ...
1320 'YMaths', '', ...
1321 'ZMaths', '', ...
1322 'XMaths', '');
1323 case 'cdata'
1324 out = append(out, 'type', 'tsdata', ...
1325 'Xlabel', 'Index', ...
1326 'Ylabel', 'Value');
1327 otherwise
1328 out = plist();
1329 end
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792