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