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
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141 VERSION = '$Id: iplot.m,v 1.25 2008/02/12 09:29:24 mauro Exp $';
0142 CATEGORY = 'Output';
0143 bs = [];
0144
0145 if (nargin == 2 || nargin == 3) &&...
0146 isa(varargin{1}, 'ao') &&...
0147 ischar(varargin{2})
0148 if strcmp(varargin{2}, 'Params')
0149 if nargin == 2
0150 varargout{1} = getDefaultPlist();
0151 else
0152 varargout{1} = getDefaultPlist(varargin{3});
0153 end
0154 return
0155 elseif strcmp(varargin{2}, 'Version')
0156 varargout{1} = VERSION;
0157 return
0158 elseif strcmp(varargin{2}, 'Category')
0159 varargout{1} = CATEGORY;
0160 return
0161 end
0162 end
0163
0164
0165
0166 in_names = {};
0167 for ii = 1:nargin
0168 in_names{end+1} = inputname(ii);
0169 end
0170
0171 [as, upl, invars] = collect_inputs(varargin, in_names);
0172
0173
0174
0175 tsAOs = [];
0176 fsAOs = [];
0177 xyAOs = [];
0178 xyzAOs = [];
0179 cAOs = [];
0180
0181 for j=1:numel(as)
0182 switch class(as(j).data)
0183 case 'tsdata'
0184 tsAOs = [tsAOs as(j)];
0185 case 'fsdata'
0186 fsAOs = [fsAOs as(j)];
0187 case 'xydata'
0188 xyAOs = [xyAOs as(j)];
0189 case 'xyzdata'
0190 xyzAOs = [xyzAOs as(j)];
0191 case 'cdata'
0192 cAOs = [cAOs as(j)];
0193 otherwise
0194 warning('!!! Unknown data type %s', class(as(j).data));
0195 end
0196 end
0197
0198
0199
0200 hfig = [];
0201 hax = [];
0202 hli = [];
0203
0204
0205
0206
0207 dpl = getDefaultPlist('tsdata');
0208
0209 pl = combine(upl, dpl);
0210
0211 [hf, ha, hl] = xy_plot(tsAOs, pl);
0212 hfig = [hfig hf];
0213 hax = [hax ha];
0214 hli = [hli hl];
0215
0216
0217
0218
0219 dpl = getDefaultPlist('xydata');
0220
0221 pl = combine(upl, dpl);
0222
0223 [hf, ha, hl] = xy_plot(xyAOs, pl);
0224 hfig = [hfig hf];
0225 hax = [hax ha];
0226 hli = [hli hl];
0227
0228
0229
0230
0231 dpl = getDefaultPlist('xyzdata');
0232
0233 pl = combine(upl, dpl);
0234
0235 [hf, ha, hl] = xyz_plot(xyzAOs, pl);
0236 hfig = [hfig hf];
0237 hax = [hax ha];
0238 hli = [hli hl];
0239
0240
0241
0242
0243 dpl = getDefaultPlist('cdata');
0244
0245 pl = combine(upl, dpl);
0246
0247 [hf, ha, hl] = y_plot(cAOs, pl);
0248 hfig = [hfig hf];
0249 hax = [hax ha];
0250 hli = [hli hl];
0251
0252
0253
0254
0255 dpl = getDefaultPlist('fsdata');
0256
0257 pl = combine(upl, dpl);
0258
0259 [hf, ha, hl] = fs_plot(fsAOs, pl);
0260 hfig = [hfig hf];
0261 hax = [hax ha];
0262 hli = [hli hl];
0263
0264
0265 if nargout == 1
0266 varargout{1} = hfig;
0267 end
0268 if nargout == 2
0269 varargout{1} = hfig;
0270 varargout{2} = hax;
0271 end
0272 if nargout == 3
0273 varargout{1} = hfig;
0274 varargout{2} = hax;
0275 varargout{3} = hli;
0276 end
0277
0278 if nargout > 3
0279 error('### Incorrect number of outputs');
0280 end
0281
0282
0283
0284
0285
0286 function varargout = fs_plot(varargin)
0287
0288 aos = varargin{1};
0289 pl = varargin{2};
0290
0291
0292 arrangement = find(pl, 'Arrangement');
0293 colors = find(pl, 'Colors');
0294
0295 linecolors = find(pl, 'LineColors');
0296 linestyles = find(pl, 'LineStyles');
0297 markers = find(pl, 'Markers');
0298 linewidths = find(pl, 'LineWidths');
0299 legends = find(pl, 'Legends');
0300 ylabels = find(pl, 'YLabels');
0301 xlabels = find(pl, 'XLabels');
0302 yscales = find(pl, 'YScales');
0303 xscales = find(pl, 'XScales');
0304 yranges = find(pl, 'YRanges');
0305 xranges = find(pl, 'XRanges');
0306 xmaths = find(pl, 'XMaths');
0307 ymaths = find(pl, 'YMaths');
0308
0309 complexPlotType = find(pl, 'complexPlotType');
0310
0311
0312 if iscell(legends)
0313 legendsOn = 1;
0314 else
0315 if strcmpi(legends, 'off')
0316 legendsOn = 0;
0317 else
0318 legendsOn = 1;
0319 legends = [];
0320 end
0321 end
0322
0323 if ~iscell(linewidths), linewidths = {linewidths}; end
0324 if ~iscell(linestyles), linestyles = {linestyles}; end
0325 if ~iscell(linecolors), linecolors = {linecolors}; end
0326 if ~iscell(markers), markers = {markers}; end
0327 if ~iscell(legends), legends = {legends}; end
0328 if ~iscell(ylabels), ylabels = {ylabels}; end
0329 if ~iscell(xlabels), xlabels = {xlabels}; end
0330 if ~iscell(xmaths), xmaths = {xmaths}; end
0331 if ~iscell(ymaths), ymaths = {ymaths}; end
0332 if ~iscell(xscales), xscales = {xscales}; end
0333 if ~iscell(yscales), yscales = {yscales}; end
0334 if ~iscell(xranges), xranges = {xranges}; end
0335 if ~iscell(yranges), yranges = {yranges}; end
0336
0337
0338
0339 tsfig = [];
0340 tsax = [];
0341 tsli = [];
0342
0343
0344 legendStr = [];
0345
0346 if ~isempty(aos)
0347
0348
0349 Na = length(aos);
0350
0351
0352 haveComplex = 0;
0353 for j=1:Na
0354 a = aos(j);
0355 y = a.data.y;
0356 ymath = '';
0357 if j<=length(ymaths)
0358 if ~isempty(ymaths{j})
0359 eval(sprintf('y = %s;', ymaths{j}));
0360 ymath = ymaths{j};
0361 end
0362 end
0363 xmath = '';
0364 if j<=length(xmaths)
0365 if ~isempty(xmaths{j})
0366 eval(sprintf('x = %s;', xmaths{j}));
0367 xmath = xmaths{j};
0368 end
0369 end
0370 if ~isreal(y)
0371 haveComplex = 1;
0372 end
0373 end
0374
0375
0376 for j=1:Na
0377
0378
0379 tsax_r = [];
0380 tsax_i = [];
0381
0382
0383 a = aos(j);
0384
0385
0386 x = a.data.x;
0387 y = a.data.y;
0388
0389 ymath = '';
0390 if j<=length(ymaths)
0391 if ~isempty(ymaths{j})
0392 eval(sprintf('y = %s;', ymaths{j}));
0393 ymath = ymaths{j};
0394 end
0395 end
0396 xmath = '';
0397 if j<=length(xmaths)
0398 if ~isempty(xmaths{j})
0399 eval(sprintf('x = %s;', xmaths{j}));
0400 xmath = xmaths{j};
0401 end
0402 end
0403
0404
0405 switch arrangement
0406 case 'single'
0407
0408 tsfig = [tsfig figure];
0409 col = colors{1};
0410
0411 if ~isreal(y)
0412
0413 tsax_r = subplot(2,1,1);
0414 tsax_i = subplot(2,1,2);
0415 tsax = [tsax tsax_r tsax_i];
0416 else
0417
0418 tsax_r = subplot(1, 1, 1);
0419 tsax = [tsax tsax_r];
0420 end
0421
0422 case 'stacked'
0423
0424 if j==1, tsfig = figure; end
0425
0426
0427 if haveComplex
0428 tsax_r = subplot(2,1,1);
0429 tsax_i = subplot(2,1,2);
0430 tsax = [tsax_r tsax_i];
0431 else
0432 tsax_r = subplot(1, 1, 1);
0433 tsax = tsax_r;
0434 end
0435 col = colors{mod(j-1,length(colors))+1};
0436 hold(tsax_r, 'on');
0437 if ishandle(tsax_i)
0438 hold(tsax_i, 'on');
0439 end
0440 case 'subplots'
0441
0442 if j == 1, tsfig = figure; end
0443 c = 1+(j-1)*2;
0444 sx = Na;
0445 sy = 2;
0446
0447 if ~isreal(y)
0448 tsax_r = subplot(sx, sy,c);
0449 tsax_i = subplot(sx, sy,c+1);
0450 tsax = [tsax tsax_r tsax_i];
0451 else
0452 tsax_r = subplot(sx, sy, c:c+1);
0453 tsax = [tsax tsax_r];
0454 end
0455 col = colors{1};
0456
0457 otherwise
0458 error('### Unknown plot arrangement');
0459 end
0460
0461
0462
0463
0464
0465 if isreal(y)
0466 li = plot(tsax_r, x, y);
0467 tsli = [tsli li];
0468 ylabelr = 'amplitude';
0469 ylabeli = 'imag';
0470 yscaleR = 'log';
0471 yscaleI = 'lin';
0472 xscaleR = 'log';
0473 xscaleI = 'lin';
0474 else
0475 switch complexPlotType
0476 case 'realimag'
0477 li = plot(tsax_r, x, y);
0478 li = [li plot(tsax_i, x, imag(y))];
0479 tsli = [tsli li];
0480 ylabelr = 'real';
0481 ylabeli = 'imag';
0482 yscaleR = 'lin';
0483 yscaleI = 'lin';
0484 xscaleR = 'lin';
0485 xscaleI = 'lin';
0486 case 'absdeg'
0487 li = plot(tsax_r, x, abs(y));
0488 li = [li plot(tsax_i, x, ltpda_phase(y))];
0489 tsli = [tsli li];
0490 ylabelr = 'amplitude';
0491 ylabeli = 'Phase [deg]';
0492 yscaleR = 'log';
0493 yscaleI = 'lin';
0494 xscaleR = 'log';
0495 xscaleI = 'log';
0496 case 'absrad'
0497 li = plot(tsax_r, x, abs(y));
0498 li = [li plot(tsax_i, x, angle(y))];
0499 tsli = [tsli li];
0500 ylabelr = 'amplitude';
0501 ylabeli = 'phase [rad]';
0502 yscaleR = 'log';
0503 yscaleI = 'lin';
0504 xscaleR = 'log';
0505 xscaleI = 'log';
0506 otherwise
0507 error('### Unknown plot type for complex data');
0508 end
0509 end
0510
0511
0512
0513
0514 c = 1+(j-1)*2;
0515 if c<=length(ylabels)
0516 if ~isempty(ylabels{c})
0517 ylstrR = ylabels{c};
0518 else
0519 ylstrR = ylabelr;
0520 end
0521 else
0522 ylstrR = ylabelr;
0523 end
0524 if c<length(ylabels)
0525 if ~isempty(ylabels{c+1})
0526 ylstrI = ylabels{c+1};
0527 else
0528 ylstrI = ylabeli;
0529 end
0530 else
0531 ylstrI = ylabeli;
0532 end
0533 if ~isempty(ymath)
0534 ymath = strrep(ymath, 'y', sprintf('%s', a.data.yunits));
0535 ylstrR = [ylstrR ' [' ymath ']' ];
0536 else
0537 ylstrR = [ylstrR ' [' a.data.yunits ']' ];
0538 end
0539 ylabel(tsax_r, ylstrR);
0540 if ishandle(tsax_i)
0541 ylabel(tsax_i, ylstrI);
0542 end
0543
0544
0545 if j<=length(xlabels) && ~isempty(xlabels{j})
0546 xlstr = xlabels{j};
0547 else
0548 xlstr = find(pl, 'XLabel');
0549 end
0550 if ~isempty(xmath)
0551 xmath = strrep(xmath, 'x', sprintf('%s', a.data.xunits));
0552 xlstr = [xlstr ' [' xmath ']' ];
0553 else
0554 xlstr = [xlstr ' [' a.data.xunits ']' ];
0555 end
0556 xlabel(tsax_r, xlstr);
0557 if ishandle(tsax_i)
0558 xlabel(tsax_i, xlstr);
0559 end
0560
0561
0562 grid(tsax_r, 'on');
0563 if ishandle(tsax_i)
0564 grid(tsax_i, 'on');
0565 end
0566
0567
0568 if length(yscales)==2 && strcmpi(yscales{1}, 'all')
0569 yscaleR = yscales{2};
0570 yscaleI = yscales{2};
0571 else
0572 c = 1+(j-1)*2;
0573 if c<=length(yscales)
0574 if ~isempty(yscales{c})
0575 yscaleR = yscales{c};
0576 end
0577 end
0578 if c<length(yscales)
0579 if ~isempty(yscales{c+1})
0580 yscaleI = yscales{c+1};
0581 end
0582 end
0583 end
0584
0585 set(tsax_r, 'YScale', yscaleR);
0586 if ishandle(tsax_i)
0587 set(tsax_i, 'YScale', yscaleI);
0588 end
0589
0590
0591 if length(xscales)==2 && strcmpi(xscales{1}, 'all')
0592 xscaleR = xscales{2};
0593 xscaleI = xscales{2};
0594 else
0595 c = 1+(j-1)*2;
0596 if c<=length(xscales)
0597 if ~isempty(xscales{c})
0598 xscaleR = xscales{c};
0599 end
0600 end
0601 if c<length(xscales)
0602 if ~isempty(xscales{c+1})
0603 xscaleI = xscales{c+1};
0604 end
0605 end
0606 end
0607 set(tsax_r, 'XScale', xscaleR);
0608 if ishandle(tsax_i)
0609 set(tsax_i, 'XScale', xscaleI);
0610 end
0611
0612
0613 if length(yranges)==2 && strcmpi(yranges{1}, 'all')
0614 set(tsax_r, 'YLim', yranges{2});
0615 if ishandle(tsax_i)
0616 set(tsax_i, 'YLim', yranges{2});
0617 end
0618 else
0619 c = 1+(j-1)*2;
0620 if c<=length(yranges)
0621 if ~isempty(yranges{c})
0622 set(tsax_r, 'YLim', yranges{c});
0623 end
0624 end
0625 if c<length(yranges)
0626 if ~isempty(yranges{c+1})
0627 if ishandle(tsax_i)
0628 set(tsax_i, 'YLim', yranges{c+1});
0629 end
0630 end
0631 end
0632 end
0633
0634
0635 if length(xranges)==2 && strcmpi(xranges{1}, 'all')
0636 set(tsax_r, 'XLim', xranges{2});
0637 if ishandle(tsax_i)
0638 set(tsax_i, 'XLim', xranges{2});
0639 end
0640 else
0641 c = 1+(j-1)*2;
0642 if c<=length(xranges)
0643 if ~isempty(xranges{c})
0644 set(tsax_r, 'XLim', xranges{c});
0645 end
0646 end
0647 if c<length(xranges)
0648 if ~isempty(xranges{c+1})
0649 if ishandle(tsax_i)
0650 set(tsax_i, 'XLim', xranges{c+1});
0651 end
0652 end
0653 end
0654 end
0655
0656
0657
0658
0659 if isreal(y)
0660 set(li, 'Color', col);
0661 else
0662 set(li, 'Color', col);
0663 set(li, 'Color', col);
0664 end
0665
0666
0667 if length(linecolors) == 2 && strcmpi(linecolors{1}, 'all')
0668 set(li, 'Color', linecolors{2});
0669 else
0670 if j<=length(linecolors) && ~isempty(linecolors{j})
0671 if isreal(y)
0672 set(li, 'Color', linecolors{j});
0673 else
0674 set(li, 'Color', linecolors{j});
0675 set(li, 'Color', linecolors{j});
0676 end
0677 end
0678 end
0679
0680
0681 if length(linestyles) == 2 && strcmpi(linestyles{1}, 'all')
0682 set(li, 'LineStyle', linestyles{2});
0683 else
0684 if j<=length(linestyles) && ~isempty(linestyles{j})
0685 if isreal(y)
0686 set(li, 'LineStyle', linestyles{j});
0687 else
0688 set(li, 'LineStyle', linestyles{j});
0689 set(li, 'LineStyle', linestyles{j});
0690 end
0691 end
0692 end
0693
0694
0695 if length(linewidths) == 2 && strcmpi(linewidths{1}, 'all')
0696 set(li, 'LineWidth', linewidths{2});
0697 else
0698 if j<=length(linewidths) && ~isempty(linewidths{j})
0699 if isreal(y)
0700 set(li, 'LineWidth', linewidths{j});
0701 else
0702 set(li, 'LineWidth', linewidths{j});
0703 set(li, 'LineWidth', linewidths{j});
0704 end
0705 end
0706 end
0707
0708
0709 if length(markers) == 2 && strcmpi(markers{1}, 'all')
0710 set(li, 'Marker', markers{2});
0711 else
0712 if j<=length(markers) && ~isempty(markers{j})
0713 if isreal(y)
0714 set(li, 'Marker', markers{j});
0715 else
0716 set(li, 'Marker', markers{j});
0717 set(li, 'Marker', markers{j});
0718 end
0719 end
0720 end
0721
0722
0723
0724 lstr = '';
0725 if legendsOn
0726 if j<=length(legends) && ~isempty(legends{j})
0727 lstr = legends{j};
0728 else
0729 lstr = ltpda_label(a.name);
0730 end
0731 end
0732 legendStr = [legendStr cellstr(lstr)];
0733
0734
0735 if legendsOn
0736 if strcmp(arrangement, 'single') || strcmp(arrangement, 'subplots')
0737 legend(tsax_r, legendStr{end});
0738 end
0739 end
0740
0741 end
0742
0743
0744 if legendsOn
0745 if strcmp(arrangement, 'stacked')
0746 h = legend(tsax_r, legendStr);
0747 set(h, 'FontSize', 10)
0748 end
0749 end
0750
0751 end
0752
0753
0754 if nargout > 0
0755 varargout{1} = tsfig;
0756 end
0757 if nargout > 1
0758 varargout{2} = tsax;
0759 end
0760 if nargout == 3
0761 varargout{3} = tsli;
0762 end
0763 if nargout > 3
0764 error('### Too many output arguments');
0765 end
0766
0767
0768
0769
0770 function varargout = xy_plot(varargin)
0771
0772 aos = varargin{1};
0773 pl = varargin{2};
0774
0775
0776 arrangement = find(pl, 'Arrangement');
0777 linecolors = find(pl, 'LineColors');
0778 colors = find(pl, 'Colors');
0779 linestyles = find(pl, 'LineStyles');
0780 markers = find(pl, 'Markers');
0781 linewidths = find(pl, 'LineWidths');
0782 legends = find(pl, 'Legends');
0783 ylabels = find(pl, 'YLabels');
0784 xlabels = find(pl, 'XLabels');
0785 xmaths = find(pl, 'XMaths');
0786 ymaths = find(pl, 'YMaths');
0787 yranges = find(pl, 'YRanges');
0788 xranges = find(pl, 'XRanges');
0789 yscales = find(pl, 'YScales');
0790 xscales = find(pl, 'XScales');
0791
0792
0793 if iscell(legends)
0794 legendsOn = 1;
0795 else
0796 if strcmpi(legends, 'off')
0797 legendsOn = 0;
0798 else
0799 legendsOn = 1;
0800 legends = [];
0801 end
0802 end
0803
0804 if ~iscell(linewidths), linewidths = {linewidths}; end
0805 if ~iscell(linestyles), linestyles = {linestyles}; end
0806 if ~iscell(linecolors), linecolors = {linecolors}; end
0807 if ~iscell(markers), markers = {markers}; end
0808 if ~iscell(legends), legends = {legends}; end
0809 if ~iscell(ylabels), ylabels = {ylabels}; end
0810 if ~iscell(xlabels), xlabels = {xlabels}; end
0811 if ~iscell(xmaths), xmaths = {xmaths}; end
0812 if ~iscell(ymaths), ymaths = {ymaths}; end
0813 if ~iscell(xranges), xranges = {xranges}; end
0814 if ~iscell(yranges), yranges = {yranges}; end
0815 if ~iscell(xscales), xscales = {xscales}; end
0816 if ~iscell(yscales), yscales = {yscales}; end
0817
0818
0819 tsfig = [];
0820 tsax = [];
0821 tsli = [];
0822
0823
0824 legendStr = [];
0825
0826 if ~isempty(aos)
0827
0828
0829 if strcmp(arrangement, 'stacked')
0830 T0 = 1e50;
0831 Na = length(aos);
0832 for j=1:Na
0833
0834 a = aos(j);
0835 if isa(a.data, 'tsdata')
0836 if a.data.t0.utc_epoch_milli/1000 < T0
0837 T0 = floor(a.data.t0.utc_epoch_milli/1000);
0838 end
0839 end
0840 end
0841 else
0842 T0 = 0;
0843 end
0844
0845
0846
0847 Na = length(aos);
0848 for j=1:Na
0849
0850
0851 a = aos(j);
0852 toff = 0;
0853
0854
0855 switch arrangement
0856 case 'single'
0857
0858 tsfig = [tsfig figure];
0859 tsax = subplot(1,1,1);
0860 col = colors{1};
0861 if isa(a.data, 'tsdata')
0862 torigin = a.data.t0;
0863 end
0864 case 'stacked'
0865
0866 if j==1, tsfig = figure; end
0867 tsax = subplot(1,1,1);
0868 col = colors{mod(j-1,length(colors))+1};
0869 hold on;
0870
0871 if isa(a.data, 'tsdata')
0872 toff = a.data.t0.utc_epoch_milli/1000 - T0;
0873 else
0874 toff = 0;
0875 end
0876 if isa(a.data, 'tsdata')
0877 torigin = time(T0*1000);
0878 end
0879 case 'subplots'
0880
0881 if j == 1, tsfig = figure; end
0882 tsax = [tsax subplot(Na, 1, j)];
0883 col = colors{1};
0884 if isa(a.data, 'tsdata')
0885 torigin = a.data.t0;
0886 end
0887 otherwise
0888 error('### Unknown plot arrangement');
0889 end
0890
0891
0892
0893
0894 x = a.data.x + toff;
0895 y = a.data.y;
0896
0897 ymath = '';
0898 if j<=length(ymaths)
0899 if ~isempty(ymaths{j})
0900 eval(sprintf('y = %s;', ymaths{j}));
0901 ymath = ymaths{j};
0902 end
0903 end
0904 xmath = '';
0905 if j<=length(xmaths)
0906 if ~isempty(xmaths{j})
0907 eval(sprintf('x = %s;', xmaths{j}));
0908 xmath = xmaths{j};
0909 end
0910 end
0911
0912
0913
0914 li = plot(tsax(end), x, y);
0915 tsli = [tsli li];
0916 if isa(a.data, 'tsdata')
0917 title(sprintf('Time origin: %s', torigin.time_str));
0918 end
0919
0920
0921
0922 if j<=length(ylabels) && ~isempty(ylabels{j})
0923 ylstr = ylabels{j};
0924 else
0925 ylstr = find(pl, 'YLabel');
0926 end
0927 if ~isempty(ymath)
0928 ymath = strrep(ymath, 'y', sprintf('%s', a.data.yunits));
0929 ylstr = [ylstr ' [' ymath ']' ];
0930 else
0931 ylstr = [ylstr ' [' a.data.yunits ']' ];
0932 end
0933 ylabel(ylstr);
0934
0935
0936 if j<=length(xlabels) && ~isempty(xlabels{j})
0937 xlstr = xlabels{j};
0938 else
0939 xlstr = find(pl, 'XLabel');
0940 end
0941 if ~isempty(xmath)
0942 xmath = strrep(xmath, 'x', sprintf('%s', a.data.xunits));
0943 xlstr = [xlstr ' [' xmath ']' ];
0944 else
0945 xlstr = [xlstr ' [' a.data.xunits ']' ];
0946 end
0947 xlabel(xlstr);
0948
0949
0950 if length(yranges) == 2 && strcmpi(yranges{1}, 'all')
0951 set(tsax(end), 'YLim', yranges{2});
0952 else
0953 if j<=length(yranges)
0954 if ~isempty(yranges{j})
0955 set(tsax(end), 'YLim', yranges{j});
0956 end
0957 end
0958 end
0959
0960
0961 yscaleR = 'lin';
0962 if length(yscales)==2 && strcmpi(yscales{1}, 'all')
0963 yscaleR = yscales{2};
0964 else
0965 if j<=length(yscales)
0966 if ~isempty(yscales{j})
0967 yscaleR = yscales{j};
0968 end
0969 end
0970 end
0971 set(tsax(end), 'YScale', yscaleR);
0972
0973
0974 xscaleR = 'lin';
0975 if length(xscales)==2 && strcmpi(xscales{1}, 'all')
0976 xscaleR = xscales{2};
0977 else
0978 if j<=length(xscales)
0979 if ~isempty(xscales{j})
0980 xscaleR = xscales{j};
0981 end
0982 end
0983 end
0984 set(tsax(end), 'XScale', xscaleR);
0985
0986
0987 if length(xranges) == 2 && strcmpi(xranges{1}, 'all')
0988 set(tsax(end), 'XLim', xranges{2});
0989 else
0990 if j<=length(xranges)
0991 if ~isempty(xranges{j})
0992 set(tsax(end), 'XLim', xranges{j});
0993 end
0994 end
0995 end
0996
0997
0998 grid(tsax(end), 'on');
0999
1000
1001
1002
1003 set(li, 'Color', col);
1004
1005
1006 if length(linecolors) == 2 && strcmpi(linecolors{1}, 'all')
1007 set(li, 'Color', linecolors{2});
1008 else
1009 if j<=length(linecolors) && ~isempty(linecolors{j})
1010 set(li, 'Color', linecolors{j});
1011 end
1012 end
1013
1014
1015 if length(linestyles) == 2 && strcmpi(linestyles{1}, 'all')
1016 set(li, 'LineStyle', linestyles{2});
1017 else
1018 if j<=length(linestyles) && ~isempty(linestyles{j})
1019 set(li, 'LineStyle', linestyles{j});
1020 end
1021 end
1022
1023
1024 if length(markers) == 2 && strcmpi(markers{1}, 'all')
1025 set(li, 'Marker', markers{2});
1026 else
1027 if j<=length(markers) && ~isempty(markers{j})
1028 set(li, 'Marker', markers{j});
1029 end
1030 end
1031
1032
1033 if length(linewidths) == 2 && strcmpi(linewidths{1}, 'all')
1034 set(li, 'LineWidth', linewidths{2});
1035 else
1036 if j<=length(linewidths) && ~isempty(linewidths{j})
1037 set(li, 'LineWidth', linewidths{j});
1038 end
1039 end
1040
1041
1042 lstr = '';
1043 if legendsOn
1044 if j<=length(legends) && ~isempty(legends{j})
1045 lstr = legends{j};
1046 else
1047 lstr = ltpda_label(a.name);
1048 end
1049 end
1050 legendStr = [legendStr cellstr(lstr)];
1051
1052
1053 if legendsOn
1054 if strcmp(arrangement, 'single') || strcmp(arrangement, 'subplots')
1055 legend(legendStr{end});
1056 end
1057 end
1058 end
1059
1060
1061 if legendsOn
1062 if strcmp(arrangement, 'stacked')
1063 h = legend(legendStr);
1064 set(h, 'FontSize', 10)
1065 end
1066 end
1067
1068 end
1069
1070
1071 if nargout > 0
1072 varargout{1} = tsfig;
1073 end
1074 if nargout > 1
1075 varargout{2} = tsax;
1076 end
1077 if nargout == 3
1078 varargout{3} = tsli;
1079 end
1080 if nargout > 3
1081 error('### Too many output arguments');
1082 end
1083
1084
1085
1086
1087
1088 function varargout = y_plot(varargin)
1089
1090 aos = varargin{1};
1091 pl = varargin{2};
1092
1093
1094 arrangement = find(pl, 'Arrangement');
1095 linecolors = find(pl, 'LineColors');
1096 colors = find(pl, 'Colors');
1097 linestyles = find(pl, 'LineStyles');
1098 markers = find(pl, 'Markers');
1099 linewidths = find(pl, 'LineWidths');
1100 legends = find(pl, 'Legends');
1101 ylabels = find(pl, 'YLabels');
1102 xlabels = find(pl, 'XLabels');
1103 xmaths = find(pl, 'XMaths');
1104 ymaths = find(pl, 'YMaths');
1105 yranges = find(pl, 'YRanges');
1106 xranges = find(pl, 'XRanges');
1107 yscales = find(pl, 'YScales');
1108 xscales = find(pl, 'XScales');
1109 if ~iscell(xscales), xscales = {xscales}; end
1110 if ~iscell(yscales), yscales = {yscales}; end
1111
1112
1113 if iscell(legends)
1114 legendsOn = 1;
1115 else
1116 if strcmp(legends, 'off')
1117 legendsOn = 0;
1118 else
1119 legendsOn = 1;
1120 legends = [];
1121 end
1122 end
1123
1124 if ~iscell(linewidths), linewidths = {linewidths}; end
1125 if ~iscell(linestyles), linestyles = {linestyles}; end
1126 if ~iscell(linecolors), linecolors = {linecolors}; end
1127 if ~iscell(markers), markers = {markers}; end
1128 if ~iscell(legends), legends = {legends}; end
1129 if ~iscell(ylabels), ylabels = {ylabels}; end
1130 if ~iscell(xlabels), xlabels = {xlabels}; end
1131 if ~iscell(xmaths), xmaths = {xmaths}; end
1132 if ~iscell(ymaths), ymaths = {ymaths}; end
1133 if ~iscell(xranges), xranges = {xranges}; end
1134 if ~iscell(yranges), yranges = {yranges}; end
1135
1136
1137 tsfig = [];
1138 tsax = [];
1139 tsli = [];
1140
1141
1142 legendStr = [];
1143
1144 if ~isempty(aos)
1145
1146
1147 Na = length(aos);
1148 for j=1:Na
1149
1150
1151 a = aos(j);
1152
1153
1154 switch arrangement
1155 case 'single'
1156
1157 tsfig = [tsfig figure];
1158 tsax = subplot(1,1,1);
1159 col = colors{1};
1160
1161 case 'stacked'
1162
1163 if j==1, tsfig = figure; end
1164 tsax = subplot(1,1,1);
1165 col = colors{mod(j-1,length(colors))+1};
1166 hold on;
1167
1168 case 'subplots'
1169
1170 if j == 1, tsfig = figure; end
1171 tsax = [tsax subplot(Na, 1, j)];
1172 col = colors{1};
1173
1174 otherwise
1175 error('### Unknown plot arrangement');
1176 end
1177
1178
1179 if isreal(a.data.y)
1180 x = 1:length(a.data.y);
1181 y = a.data.y;
1182 else
1183 x = real(a.data.y);
1184 y = imag(a.data.y);
1185 end
1186
1187 ymath = '';
1188 if j<=length(ymaths)
1189 if ~isempty(ymaths{j})
1190 eval(sprintf('y = %s;', ymaths{j}));
1191 ymath = ymaths{j};
1192 end
1193 end
1194 xmath = '';
1195 if j<=length(xmaths)
1196 if ~isempty(xmaths{j})
1197 eval(sprintf('x = %s;', xmaths{j}));
1198 xmath = xmaths{j};
1199 end
1200 end
1201
1202
1203
1204 idcs = plot(tsax(end), x, y);
1205 tsli = [tsli idcs(1:end).'];
1206
1207
1208
1209
1210 if j<=length(ylabels) && ~isempty(ylabels{j})
1211 ylstr = ylabels{j};
1212 else
1213 ylstr = find(pl, 'YLabel');
1214 end
1215 if ~isempty(ymath)
1216 ymath = strrep(ymath, 'y', sprintf('%s', a.data.yunits));
1217 ylstr = [ylstr ' [' ymath ']' ];
1218 else
1219 ylstr = [ylstr ' [' a.data.yunits ']' ];
1220 end
1221 ylabel(ylstr);
1222
1223
1224 if j<=length(xlabels) && ~isempty(xlabels{j})
1225 xlstr = xlabels{j};
1226 else
1227 xlstr = find(pl, 'XLabel');
1228 end
1229 if ~isempty(xmath)
1230 xmath = strrep(xmath, 'x', sprintf('%s', a.data.xunits));
1231 xlstr = [xlstr ' [' xmath ']' ];
1232 else
1233 xlstr = [xlstr ' [' a.data.xunits ']' ];
1234 end
1235 xlabel(xlstr);
1236
1237
1238 yscaleR = 'lin';
1239 if length(yscales)==2 && strcmpi(yscales{1}, 'all')
1240 yscaleR = yscales{2};
1241 else
1242 if j<=length(yscales)
1243 if ~isempty(yscales{j})
1244 yscaleR = yscales{j};
1245 end
1246 end
1247 end
1248 set(tsax(end), 'YScale', yscaleR);
1249
1250
1251 xscaleR = 'lin';
1252 if length(xscales)==2 && strcmpi(xscales{1}, 'all')
1253 xscaleR = xscales{2};
1254 else
1255 if j<=length(xscales)
1256 if ~isempty(xscales{j})
1257 xscaleR = xscales{j};
1258 end
1259 end
1260 end
1261 set(tsax(end), 'XScale', xscaleR);
1262
1263
1264 if length(yranges) == 2 && strcmpi(yranges{1}, 'all')
1265 set(tsax(end), 'YLim', yranges{2});
1266 else
1267 if j<=length(yranges)
1268 if ~isempty(yranges{j})
1269 set(tsax(end), 'YLim', yranges{j});
1270 end
1271 end
1272 end
1273
1274
1275 if length(xranges) == 2 && strcmpi(xranges{1}, 'all')
1276 set(tsax(end), 'XLim', xranges{2});
1277 else
1278 if j<=length(xranges)
1279 if ~isempty(xranges{j})
1280 set(tsax(end), 'XLim', xranges{j});
1281 end
1282 end
1283 end
1284
1285
1286 grid(tsax(end), 'on');
1287
1288
1289
1290
1291 set(idcs, 'Color', col);
1292
1293
1294 if length(linecolors) == 2 && strcmpi(linecolors{1}, 'all')
1295 set(idcs, 'Color', linecolors{2});
1296 else
1297 if j<=length(linecolors) && ~isempty(linecolors{j})
1298 set(idcs, 'Color', linecolors{j});
1299 end
1300 end
1301
1302
1303 if length(linestyles) == 2 && strcmpi(linestyles{1}, 'all')
1304 set(idcs, 'LineStyle', linestyles{2});
1305 else
1306 if j<=length(linestyles) && ~isempty(linestyles{j})
1307 set(idcs, 'LineStyle', linestyles{j});
1308 end
1309 end
1310
1311
1312 if length(markers) == 2 && strcmpi(markers{1}, 'all')
1313 set(idcs, 'Marker', markers{2});
1314 else
1315 if j<=length(markers) && ~isempty(markers{j})
1316 set(idcs, 'Marker', markers{j});
1317 end
1318 end
1319
1320
1321 if length(linewidths) == 2 && strcmpi(linewidths{1}, 'all')
1322 set(idcs, 'LineWidth', linewidths{2});
1323 else
1324 if j<=length(linewidths) && ~isempty(linewidths{j})
1325 set(idcs, 'LineWidth', linewidths{j});
1326 end
1327 end
1328
1329
1330 if legendsOn
1331 if j<=length(legends) && ~isempty(legends{j})
1332 legendStr = [legendStr legends(j)];
1333 else
1334 lstr = ltpda_label(a.name);
1335 legendStr = [legendStr cellstr(lstr)];
1336 end
1337 end
1338
1339
1340 if legendsOn
1341 if strcmp(arrangement, 'single') || strcmp(arrangement, 'subplots')
1342 legend(legendStr{end});
1343 end
1344 end
1345 end
1346
1347
1348 if legendsOn
1349 if strcmp(arrangement, 'stacked')
1350 h = legend(legendStr);
1351 set(h, 'FontSize', 10)
1352 end
1353 end
1354
1355 end
1356
1357
1358 if nargout > 0
1359 varargout{1} = tsfig;
1360 end
1361 if nargout > 1
1362 varargout{2} = tsax;
1363 end
1364 if nargout == 3
1365 varargout{3} = tsli;
1366 end
1367 if nargout > 3
1368 error('### Too many output arguments');
1369 end
1370
1371
1372
1373
1374 function varargout = xyz_plot(varargin)
1375
1376 aos = varargin{1};
1377 pl = varargin{2};
1378
1379
1380 arrangement = find(pl, 'Arrangement');
1381 linecolors = find(pl, 'LineColors');
1382 colors = find(pl, 'Colors');
1383 linestyles = find(pl, 'LineStyles');
1384 linewidths = find(pl, 'LineWidths');
1385 legends = find(pl, 'Legends');
1386 zlabels = find(pl, 'ZLabels');
1387 ylabels = find(pl, 'YLabels');
1388 xlabels = find(pl, 'XLabels');
1389 xmaths = find(pl, 'XMaths');
1390 ymaths = find(pl, 'YMaths');
1391 zmaths = find(pl, 'ZMaths');
1392
1393
1394 if iscell(legends)
1395 legendsOn = 1;
1396 else
1397 if strcmp(legends, 'off')
1398 legendsOn = 0;
1399 else
1400 legendsOn = 1;
1401 legends = [];
1402 end
1403 end
1404
1405
1406 tsfig = [];
1407 tsax = [];
1408 tsli = [];
1409
1410
1411 legendStr = [];
1412
1413 if ~isempty(aos)
1414
1415
1416 Na = length(aos);
1417 for j=1:Na
1418
1419
1420 a = aos(j);
1421
1422
1423 switch arrangement
1424 case 'single'
1425
1426 tsfig = [tsfig figure];
1427 tsax = subplot(1,1,1);
1428
1429 case 'subplots'
1430
1431 if j == 1, tsfig = figure; end
1432 tsax = [tsax subplot(Na, 1, j)];
1433
1434 otherwise
1435 error('### Unknown plot arrangement');
1436 end
1437
1438
1439 x = a.data.x;
1440 y = a.data.y;
1441 z = a.data.z;
1442
1443
1444 ymath = '';
1445 if j<=length(ymaths)
1446 if ~isempty(ymaths{j})
1447 eval(sprintf('y = %s;', ymaths{j}));
1448 ymath = ymaths{j};
1449 end
1450 end
1451 xmath = '';
1452 if j<=length(xmaths)
1453 if ~isempty(xmaths{j})
1454 eval(sprintf('x = %s;', xmaths{j}));
1455 xmath = xmaths{j};
1456 end
1457 end
1458 zmath = '';
1459 if j<=length(zmaths)
1460 if ~isempty(zmaths{j})
1461 eval(sprintf('z = %s;', zmaths{j}));
1462 zmath = zmaths{j};
1463 end
1464 end
1465
1466
1467
1468 idcs = pcolor(x,y,z);
1469 tsli = [tsli idcs(1:end).'];
1470
1471
1472 set(idcs, 'EdgeColor', 'none');
1473
1474
1475
1476
1477 set(tsax(end), 'YDir', 'reverse');
1478
1479
1480 if j<=length(ylabels) && ~isempty(ylabels{j})
1481 ylstr = ylabels{j};
1482 else
1483 ylstr = find(pl, 'YLabel');
1484 end
1485 if ~isempty(ymath)
1486 ymath = strrep(ymath, 'y', sprintf('%s', a.data.yunits));
1487 ylstr = [ylstr ' [' ymath ']' ];
1488 else
1489 ylstr = [ylstr ' [' a.data.yunits ']' ];
1490 end
1491 ylabel(ylstr);
1492
1493
1494 if j<=length(xlabels) && ~isempty(xlabels{j})
1495 xlstr = xlabels{j};
1496 else
1497 xlstr = find(pl, 'XLabel');
1498 end
1499 if ~isempty(xmath)
1500 xmath = strrep(xmath, 'x', sprintf('%s', a.data.xunits));
1501 xlstr = [xlstr ' [' xmath ']' ];
1502 else
1503 xlstr = [xlstr ' [' a.data.xunits ']' ];
1504 end
1505 xlabel(xlstr);
1506
1507
1508 grid(tsax(end), 'on');
1509
1510
1511 if ~strcmpi(legends, 'off')
1512 if j<=length(legends) && ~isempty(legends{j})
1513 legendStr = [legendStr legends(j)];
1514 else
1515 lstr = ltpda_label(a.name);
1516 legendStr = [legendStr cellstr(lstr)];
1517 end
1518 end
1519
1520
1521 tstr = legendStr{end};
1522 if legendsOn
1523 title(tstr);
1524 end
1525
1526
1527 hc = colorbar('peer', tsax(end));
1528 if j<=length(zlabels)
1529 if ~isempty(zlabels{j})
1530 zlstr = zlabels{j};
1531 end
1532 else
1533 zlstr = find(pl, 'Zlabel');
1534 end
1535 if ~isempty(zmath), zlstr = [zlstr sprintf('\n%s', zmath)]; end
1536 ylh = get(hc, 'YLabel');
1537 set(ylh, 'String', zlstr);
1538 set(ylh, 'Fontsize', get(tsax(end), 'Fontsize'))
1539 set(ylh, 'FontName', get(tsax(end), 'FontName'))
1540 set(ylh, 'FontAngle', get(tsax(end), 'FontAngle'))
1541 set(ylh, 'FontWeight', get(tsax(end), 'FontWeight'))
1542 end
1543 end
1544
1545
1546 if nargout > 0
1547 varargout{1} = tsfig;
1548 end
1549 if nargout > 1
1550 varargout{2} = tsax;
1551 end
1552 if nargout == 3
1553 varargout{3} = tsli;
1554 end
1555 if nargout > 3
1556 error('### Too many output arguments');
1557 end
1558
1559
1560
1561
1562
1563 function out = getDefaultPlist(varargin)
1564
1565
1566 sets = {'tsdata', 'fsdata', 'cdata', 'xydata'};
1567
1568
1569 colors = getappdata(0,'ltpda_default_plot_colors');
1570
1571 if nargin == 0
1572 out = sets;
1573 return
1574 end
1575
1576 set = varargin{1};
1577
1578 out = plist('Colors', colors, ...
1579 'Arrangement', 'stacked');
1580
1581 switch set
1582 case 'fsdata'
1583 out = append(out, 'type', 'fsdata', ...
1584 'complexPlotType', 'absdeg', ...
1585 'XLabel', 'Frequency');
1586 case 'tsdata'
1587 out = append(out, 'type', 'tsdata', ...
1588 'Xlabel', 'Time', ...
1589 'Ylabel', 'Amplitude');
1590 case 'xydata'
1591 out = append(out, 'type', 'xydata', ...
1592 'Xlabel', 'X-data', ...
1593 'Ylabel', 'Y-data', ...
1594 'YMaths', '', ...
1595 'XMaths', '');
1596 case 'xyzdata'
1597 out = plist('Colors', colors, 'Arrangement', 'single', ...
1598 'type', 'xydata', ...
1599 'Xlabel', 'Time', ...
1600 'Ylabel', 'Frequency',...
1601 'Zlabel', 'Amplitude', ...
1602 'YMaths', '', ...
1603 'ZMaths', '', ...
1604 'XMaths', '');
1605 case 'cdata'
1606 out = append(out, 'type', 'tsdata', ...
1607 'Xlabel', 'Index', ...
1608 'Ylabel', 'Value');
1609 otherwise
1610 out = plist();
1611 end
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
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074