function handles =plot_matrixyy (t, data, t2, data2, opt_strct, leg_arr, colourarr, linesize)

if nargin < 6
   linesize = 1; 
end

if nargin < 5
    colourarr = ['bgrmckbgrmckbgrmckbgrmckbgrmckbgrmck'];
end

if isempty(colourarr); colourarr = ['bgrmckbgrmckbgrmckbgrmckbgrmckbgrmck']; end

ds = 1;
shift = 0;
zero_means = 0;
plotloglog = 0;
normalize_everything = 0;

if exist('opt_strct','var')
    if ~isempty(opt_strct);
        if isfield (opt_strct,'ds'); ds = opt_strct.ds; end
        if isfield (opt_strct,'shift'); shift = opt_strct.shift; end
        if isfield (opt_strct,'zero_means'); zero_means = opt_strct.zero_means; end
        if isfield (opt_strct,'plotloglog'); plotloglog = opt_strct.plotloglog; end
        if isfield (opt_strct,'normalize_everything'); normalize_everything = opt_strct.normalize_everything; end
    end
end

if normalize_everything
   for jj = 1:size(data,2)
       xtemp = data(:,jj);
       xtemp = xtemp - mean(xtemp);
       xtemp = xtemp / std(xtemp);
       data(:,jj) = xtemp;
   end
   
   for jj = 1:size(data2,2)
       xtemp = data2(:,jj);
       xtemp = xtemp - mean(xtemp);
       xtemp = xtemp / std(xtemp);
       data2(:,jj) = xtemp;
   end
   
end

t = downsample(t, ds);
for i = 1:size(data,2)
    plotdata = data(:,i);
    plotdata2 = data2(:,i);
    if zero_means; plotdata = plotdata - mean(plotdata); end
    if zero_means; plotdata2 = plotdata2 - mean(plotdata2); end
    plotdata = downsample(plotdata, ds);
    if ~plotloglog
        [handles.plot handles.ax1 handles.ax2] = plotyy (t, plotdata + (i-1)*shift, t2, plotdata2 + (i-1)*shift); hold on;
    else
%         % Not yet implemented
%         loglog(t, plotdata, colourarr(i), 'LineWidth',linesize); hold on;
%         if (shift ~= 0)
%             handles.plotlog = loglog(t, plotdata + (i-1)*shift, colourarr(i), 'LineWidth',linesize); hold on;
%         end
    end
end

if exist('leg_arr','var')
    if ~isempty(leg_arr)
        for i = 1:length(leg_arr)
            tempstr = leg_arr{i};
            leg_arr{i} = strrep (leg_arr{i}, '_', ' ');
        end
        handles.legend = legend (leg_arr);
    end
end




end