diff m-toolbox/test/new_plot/test_miplot.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m-toolbox/test/new_plot/test_miplot.m	Wed Nov 23 19:22:13 2011 +0100
@@ -0,0 +1,291 @@
+clear all
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%         TSDATA OBJECTS
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% Make test AOS
+
+p      = plist('waveform', 'noise', 'fs', 10, 'nsecs', 10);
+tsao1  = ao(p);
+p      = plist('waveform', 'sine wave', 'fs', 10, 'nsecs', 10, 'f', 1, 'phi', 0);
+tsao2  = ao(p);
+
+tsvec = [tsao1 tsao2];
+tsmat = [tsao1 tsao2; tsao1 tsao2];
+
+%% Default plot
+miplot(tsao1, tsao2)
+miplot(tsvec)
+miplot(tsmat)
+
+%% Change colors and line styles
+
+pl = plist('Colors', {'g', 'k', 'm'}, 'LineStyles', {'--'}, 'LineWidths', [1 4]);
+miplot(tsao1, tsao2, pl);
+
+%% Change arrangement to single plots
+
+pl = plist('Arrangement', 'single');
+miplot(tsao1, tsao2, pl);
+
+%% Change arrangement to subplots
+
+% Also override the second legend text and the first line style
+pl = plist('Arrangement', 'subplots', 'LineStyles', {'--'}, 'Legends', {'', 'My Sine Wave'});
+miplot(tsao1, tsao2, pl);
+
+%% Changel ylabel
+
+% Overide the Y-labels
+pl = plist('Arrangement', 'subplots', 'YLabels', {'signal 1', 'signal 2'}, 'Legends', {'', 'My Sine Wave'});
+miplot(tsao1, tsao2, pl);
+
+%% Changel xlabel
+
+% Overide the X-labels
+pl = plist('Arrangement', 'subplots', 'XLabels', {'', 'Time-stamps'}, 'Legends', {'', 'My Sine Wave'});
+miplot(tsao1, tsao2, pl);
+
+%% No legends
+
+pl = plist('Arrangement', 'subplots', 'Legends', 'off');
+miplot(tsao1, tsao2, pl);
+
+%% Check math functions
+
+pl = plist('Arrangement', 'subplots', 'YMaths', 'y.^2', 'XMaths', {'', 'log(x)'});
+miplot(tsao1, tsao2, pl);
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%         FSDATA OBJECTS
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%% Make test AOs
+
+fsd1 = resp(miir(plist('fs', 100)), plist('f', logspace(-4, log10(50), 1000)));
+fsd1 = set(fsd1, 'yunits', 'm/V');
+fsd2 = ltpda_pwelch(tsao1+tsao2);
+fsd3 = fsd2*10;
+fsd4 = resp(miir(plist('type', 'highpass')));
+fsd4 = set(fsd4, 'yunits', 'm/V');
+
+%% Default plot
+
+miplot(fsd1, fsd2, fsd3, fsd4)
+
+%% Subplots
+
+pl = plist('Arrangement', 'subplots');
+miplot(fsd1, fsd2, fsd3, fsd4, pl)
+
+%% Single plots
+
+pl = plist('Arrangement', 'single');
+miplot(fsd1, fsd2, fsd3, fsd4, pl)
+
+%% Use math function on y-data
+
+pl = plist('Ymaths', {'abs(y)'});
+miplot(fsd1, pl);
+
+%% Change colors and line styles
+
+pl = plist('Colors', {'g', 'k', 'm'}, 'LineStyles', {'--'}, 'LineWidths', [1 4]);
+miplot(fsd1, fsd2, pl);
+
+%% Change arrangement to subplots
+
+% Also override the second legend text and the first line style
+pl = plist('Arrangement', 'subplots', 'LineStyles', {'--'}, 'Legends', {'', 'My Sine Wave'});
+miplot(fsd1, fsd2, pl);
+
+%% Changel ylabel
+
+% Overide the Y-labels
+pl = plist('Arrangement', 'subplots', 'YLabels', {'signal 1 mag', '', 'signal 2'}, 'Legends', {'', 'My Sine Wave'});
+miplot(fsd1, fsd2, pl);
+
+%% Changel xlabel
+
+% Overide the X-labels
+pl = plist('Arrangement', 'subplots', 'XLabels', {'', 'Freq'}, 'Legends', {'', 'My Sine Wave'});
+miplot(fsd1, fsd2, pl);
+
+%% No legends
+
+pl = plist('Arrangement', 'subplots', 'Legends', 'off');
+miplot(fsd1, fsd2, pl);
+
+%% Set Y scales
+
+pl = plist('Arrangement', 'subplots', 'YScales', {'', 'log', 'lin'});
+miplot(fsd1, fsd2, pl);
+
+%% Set X scales
+
+pl = plist('Arrangement', 'subplots', 'XScales', {'', 'lin', 'lin'});
+miplot(fsd1, fsd2, pl);
+
+%% Set Y ranges
+
+pl = plist('Arrangement', 'subplots', 'YRanges', {[0.1 10], [], [1e-3 100]});
+miplot(fsd1, fsd2, pl);
+
+
+%% Set X ranges
+
+pl = plist('Arrangement', 'subplots', 'YRanges', [0.001, 10], 'XRanges', {[0.1 10], [0 10], [0.1 10]});
+miplot(fsd1, fsd2, pl);
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%         XYDATA OBJECTS
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%% Make test AOs
+
+xy1  = ao(xydata(1:100, cos(1:100)));
+xy1  = set(xy1, 'xunits', 'NA', 'yunits', 'NA');
+xy2  = ao(xydata(1:100, sin(1:100)));
+xy2  = set(xy2, 'xunits', 'NA', 'yunits', 'NA');
+
+
+%% Default plot
+miplot(xy1, xy2)
+
+%% Use Math function on y-data
+
+pl = plist('Ymaths', {'abs(y)', 'y.^2'}, 'Xmaths', 'log(x)');
+miplot(xy1, xy2, pl);
+
+
+%% Change colors and line styles
+
+pl = plist('Colors', {'g', 'k', 'm'}, 'LineStyles', {'--'}, 'LineWidths', [1 4]);
+miplot(xy1, xy2, pl);
+
+%% Change arrangement to single plots
+
+pl = plist('Arrangement', 'single');
+miplot(xy1, xy2, pl);
+
+%% Change arrangement to subplots
+
+% Also override the second legend text and the first line style
+pl = plist('Arrangement', 'subplots', 'LineStyles', {'--'}, 'Legends', {'', 'My Sine Wave'});
+miplot(xy1, xy2, pl);
+
+%% Changel ylabel
+
+% Overide the Y-labels
+pl = plist('Arrangement', 'subplots', 'YLabels', {'signal 1', 'signal 2'}, 'Legends', {'', 'My Sine Wave'});
+miplot(xy1, xy2, pl);
+
+%% Changel xlabel
+
+% Overide the X-labels
+pl = plist('Arrangement', 'subplots', 'XLabels', {'', 'Time-stamps'}, 'Legends', {'', 'My Sine Wave'});
+miplot(xy1, xy2, pl);
+
+%% No legends
+
+pl = plist('Arrangement', 'subplots', 'Legends', 'off');
+miplot(xy1, xy2, pl);
+
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%         CDATA OBJECTS
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+%% Make test AOS
+
+c1  = ao(randn(1,10));
+c2  = ao(1:10);
+
+
+%% Default plot
+miplot(c1, c2)
+
+%% Change colors and line styles
+
+pl = plist('Colors', {'g', 'k', 'm'}, 'LineStyles', {'--'}, 'LineWidths', [1 4]);
+miplot(c1, c2, pl);
+
+%% Change arrangement to single plots
+
+pl = plist('Arrangement', 'single');
+miplot(c1, c2, pl);
+
+%% Change arrangement to subplots
+
+% Also override the second legend text and the first line style
+pl = plist('Arrangement', 'subplots', 'LineStyles', {'--'}, 'Legends', {'', 'My Sine Wave'});
+miplot(c1, c2, pl);
+
+%% Changel ylabel
+
+% Overide the Y-labels
+pl = plist('Arrangement', 'subplots', 'YLabels', {'signal 1', 'signal 2'}, 'Legends', {'', 'My Sine Wave'});
+miplot(c1, c2, pl);
+
+%% Changel xlabel
+
+% Overide the X-labels
+pl = plist('Arrangement', 'subplots', 'XLabels', {'', 'Time-stamps'}, 'Legends', {'', 'My Sine Wave'});
+miplot(c1, c2, pl);
+
+%% No legends
+
+pl = plist('Arrangement', 'subplots', 'Legends', 'off');
+miplot(c1, c2, pl);
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%         XYZ DATA OBJECTS
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%% Test data
+nsecs = 100;
+fs    = 100;
+p     = plist('waveform', 'noise', 'fs', fs, 'nsecs', nsecs);
+n     = ao(p);
+p     = plist('waveform', 'chirp', 'fs', fs, 'nsecs', nsecs, 'f0', 0, 'f1', 50, 't1', nsecs);
+s     = ao(p);
+
+a = s+n;
+
+% Make spectrogram
+
+sxx = spectrogram(a, plist('Nfft', 4*fs));
+rxx = spectrogram(s, plist('Nfft', 4*fs));
+
+%% Plot
+
+pl = plist('Arrangement', 'subplots', 'YMaths', {'log10(y)', 'log10(y)'}, ...
+          'Zmaths', {'20*log10(z)', '20*log10(z)'}, ...
+          'Xmaths', {'log10(x)'});
+
+miplot(sxx, rxx, pl)
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%         MIXED OBJECTS
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%% XY and TSDATA
+miplot(xy1, tsao1, xy2, tsao2, c1)
+