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