% A test script from ao/gnuplot
% 
% M Hewitson 26-02-2010
% 
% $Id: test_ao_gnuplot.m,v 1.2 2010/03/01 09:19:06 hewitson Exp $
% 

clear all;

%% Time-series

a1 = ao(plist('tsfcn', 'sin(2*pi*t)', 'fs', 10000, 'nsecs', 10, 'yunits', 'm^2 V^-0.5'))
a1.setName('My Nice AO 1');
a1.setPlotinfo(plist('color', 'b', 'linewidth', 6, 'linestyle', '--', 'marker', ''));

a2 = ao(plist('tsfcn', 'sin(2*pi*0.5*t)', 'fs', 3000, 'nsecs', 10, 'yunits', 'm^2 V^-0.5'))
a2.setName('My Nice AO 2');
a2.setPlotinfo(plist('color', [0.2 0.2 0.2], 'linewidth', 2, 'linestyle', '-', 'marker', ''));

%% Plot

outfile = 'test.pdf';
fnames = gnuplot(a1, a2, plist('terminal', 'pdf enhanced', ...
  'output', outfile, ...
  'preamble', {'set title "my nice plot"', 'set key outside top right'}, ...
  'markerscale', 3))

cmd = sprintf('open %s', fnames{1});
system(cmd)


%% Subplots

outfile = 'test.pdf';

fnames = gnuplot(a1, a2, plist('arrangement', 'subplots', 'terminal', 'pdf enhanced', ...
  'output', outfile, ...
  'preamble', {'set title "my nice plot"', 'set key outside top right'}, ...
  'markerscale', 3))

cmd = sprintf('open %s', fnames{1});
system(cmd)


%% Single plots

outfile = 'test.pdf';

fnames = gnuplot(a1, a2, plist('arrangement', 'single', 'terminal', 'pdf enhanced', ...
  'output', outfile, 'outdir', '.', ...
  'preamble', {'set title "my nice plot"', 'set key outside top right'}, ...
  'markerscale', 3))

for jj=1:numel(fnames)
  cmd = sprintf('open %s', fnames{jj});
  system(cmd)
end

%% Frequency-series

a = ao(plist('tsfcn', 'randn(size(t))', 'fs', 100, 'nsecs', 100));
axx = a.lpsd;

pzm = pzmodel(1, 1, 10);
bxx = pzm.resp(plist('fs', logspace(-1,2,1000)));


%% Single plots
outfile = 'test.pdf';

fnames = gnuplot(axx,bxx, plist('arrangement', 'single', 'terminal', 'pdf enhanced', ...
  'output', outfile, 'outdir', '.', ...
  'preamble', {'set title "my nice plot"', 'set key outside top right', ...
               'unset logscale', 'set logscale x'}, ...
  'markerscale', 3))

for jj=1:numel(fnames)
  cmd = sprintf('open %s', fnames{jj});
  system(cmd)
end

%% Stacked

outfile = 'test.pdf';

fnames = gnuplot(axx,bxx, plist('arrangement', 'stacked', 'terminal', 'pdf enhanced', ...
  'output', outfile, 'outdir', '.', ...
  'preamble', {'set title "my nice plot"', 'set key outside top right'}, ...
  'markerscale', 3))

for jj=1:numel(fnames)
  cmd = sprintf('open %s', fnames{jj});
  system(cmd)
end




