function addTs(h,ts,varargin)

%% If the destination axes is not specied expand the number of axes by 1 to
%% accomodate the additional plot
s = size(ts.Data);
if nargin==2
    h.addaxes;
    axespos = h.axesgrid.size(1);
else
    axespos = varargin{1};
end

%% Add the new waveform. Local function used to circumevent the behavior
%% of the @waveform localize method which will not allow a datasrc to
%% direct all components of a response to the same channel
r = h.addwave(tsguis.tssource('Timeseries',ts),axespos,@freqresp);

%% Add interval selection menus for each response
r.View.addMenu(h)

%% Add a listener to the @timeseries datachange event which fires the 
%% waveform datachanged event
r.addlisteners(handle.listener(r.DataSrc.Timeseries,'datachange', ...
    {@localDataChange r}));
%% Add a listener to the timeseries name property of the timePlot Data
%% to update the first column of the axes table
r.addlisteners(handle.listener(ts,ts.findprop('Name'),'PropertyPostSet',...
    {@localDataChange r}));

%% Extend time focus if needed
if length(h.Waves)>1
    focus = h.getfocus;
else
    focus = [inf -inf]; % If this is the first wave the focus = time
                        % range of the first wave
end
h.setfocus(r.Data.Focus);

%% Update title
if length(h.Waves)==1
    h.axesgrid.Title = sprintf('Periodogram of %s',ts.Name);
else
    h.axesgrid.Title = 'Periodogram of Multiple Time Series';
end
S = warning('off','all'); % Disable "Some data is missing @resppack warn..."
h.draw
warning(S);       

function localDataChange(eventSrc, eventData,r)

%% @timeseries datachange listener callback
S = warning('off','all'); % Disable "Some data is missing @resppack warn..."
r.DataSrc.send('SourceChanged');
warning(S);