function  plot_by_direction( gap, data1,data2)
figure;
index = 8:0.2:11.8;
freq = [1, 5, 6, 13, 14];
for q = 1:length(freq)
    temp = squeeze(mean(data1,3));
    %tempSTD = std(temp);
    tempMAX = squeeze(max(data1,[],3));
    tempMIN = squeeze(min(data1,[],3));
    subplot(length(freq),1,q);
    plot(1:gap:size(data1,2),temp(freq(q),1:gap:size(data1,2)),'r','LineWidth',2);
    hold on;
    plot(1:gap:size(data1,2),tempMAX(freq(q),1:gap:size(data1,2)),'--r','LineWidth',1);
    plot(1:gap:size(data1,2),tempMIN(freq(q),1:gap:size(data1,2)),'--r','LineWidth',1);
    
    temp2 = squeeze(mean(data2,3));
    tempSTD = std(temp2);
    tempMAX = squeeze(max(data2,[],3));
    tempMIN = squeeze(min(data2,[],3));
    plot(1:gap:size(data2,2),temp2(freq(q),1:gap:size(data2,2)),'k','LineWidth',2);
    plot(1:gap:size(data2,2),tempMAX(freq(q),1:gap:size(data2,2)),'--k','LineWidth',1);
    plot(1:gap:size(data2,2),tempMIN(freq(q),1:gap:size(data2,2)),'--k','LineWidth',1);
    %legend('Normal', 'Block9Hz');
    hold off
    title(['Freq: ' num2str(index(freq(q))) ...
           ', corr= ' num2str(corr2(temp(freq(q),1:gap:size(data1,2)),temp2(freq(q),1:gap:size(data2,2))))...
        ]);
    %ylim([0 0.6]);
end
figure;
freq = [4, 11, 12, 19,20];
for q = 1:length(freq)
    temp = squeeze(mean(data1,3));
    tempSTD = std(temp);
    tempMAX = squeeze(max(data1,[],3));
    tempMIN = squeeze(min(data1,[],3));
    subplot(length(freq),1,q);
    plot(1:gap:size(data1,2),temp(freq(q),1:gap:size(data1,2)),'r','LineWidth',2);
    hold on;
    plot(1:gap:size(data1,2),tempMAX(freq(q),1:gap:size(data1,2)),'--r','LineWidth',1);
    plot(1:gap:size(data1,2),tempMIN(freq(q),1:gap:size(data1,2)),'--r','LineWidth',1);
    temp2 = squeeze(mean(data2,3));
    tempSTD = std(temp2);
    tempMAX = squeeze(max(data2,[],3));
    tempMIN = squeeze(min(data2,[],3));
    plot(1:gap:size(data2,2),temp2(freq(q),1:gap:size(data2,2)),'k','LineWidth',2);
    plot(1:gap:size(data2,2),tempMAX(freq(q),1:gap:size(data2,2)),'--k','LineWidth',1);
    plot(1:gap:size(data2,2),tempMIN(freq(q),1:gap:size(data2,2)),'--k','LineWidth',1);
    %legend('Normal', 'Block9Hz');
    hold off
    title(['Freq: ' num2str(index(freq(q))) ' ,corr= ' ...
        num2str(corr2(temp(freq(q),1:gap:size(data1,2)),...
        temp2(freq(q),1:gap:size(data2,2))))]);
    %ylim([0 0.6]);
end
figure;
freq = [3, 9, 10, 17, 18];
for q = 1:length(freq)
    temp = squeeze(mean(data1,3));
    tempSTD = std(temp);
    tempMAX = squeeze(max(data1,[],3));
    tempMIN = squeeze(min(data1,[],3));
    subplot(length(freq),1,q);
    plot(1:gap:size(data1,2),temp(freq(q),1:gap:size(data1,2)),'r','LineWidth',2);
    hold on;
    plot(1:gap:size(data1,2),tempMAX(freq(q),1:gap:size(data1,2)),'--r','LineWidth',1);
    plot(1:gap:size(data1,2),tempMIN(freq(q),1:gap:size(data1,2)),'--r','LineWidth',1);
    temp2 = squeeze(mean(data2,3));
    tempSTD = std(temp2);
    tempMAX = squeeze(max(data2,[],3));
    tempMIN = squeeze(min(data2,[],3));
    plot(1:gap:size(data2,2),temp2(freq(q),1:gap:size(data2,2)),'k','LineWidth',2);
    plot(1:gap:size(data2,2),tempMAX(freq(q),1:gap:size(data2,2)),'--k','LineWidth',1);
    plot(1:gap:size(data2,2),tempMIN(freq(q),1:gap:size(data2,2)),'--k','LineWidth',1);
    %legend('Normal', 'Block9Hz');
    hold off
    title(['Freq: ' num2str(index(freq(q))) ' ,corr= ' ...
        num2str(corr2(temp(freq(q),1:gap:size(data1,2)),...
        temp2(freq(q),1:gap:size(data2,2))))]);
    %ylim([0 0.6]);
end

figure;
freq = [2, 7, 8, 15, 16];
for q = 1:length(freq)
    temp = squeeze(mean(data1,3));
    tempSTD = std(temp);
    tempMAX = squeeze(max(data1,[],3));
    tempMIN = squeeze(min(data1,[],3));
    subplot(length(freq),1,q);
    plot(1:gap:size(data1,2),temp(freq(q),1:gap:size(data1,2)),'r','LineWidth',2);
    hold on;
    plot(1:gap:size(data1,2),tempMAX(freq(q),1:gap:size(data1,2)),'--r','LineWidth',1);
    plot(1:gap:size(data1,2),tempMIN(freq(q),1:gap:size(data1,2)),'--r','LineWidth',1);
    temp2 = squeeze(mean(data2,3));
    tempSTD = std(temp2);
    tempMAX = squeeze(max(data2,[],3));
    tempMIN = squeeze(min(data2,[],3));
    plot(1:gap:size(data2,2),temp2(freq(q),1:gap:size(data2,2)),'k','LineWidth',2);
    plot(1:gap:size(data2,2),tempMAX(freq(q),1:gap:size(data2,2)),'--k','LineWidth',1);
    plot(1:gap:size(data2,2),tempMIN(freq(q),1:gap:size(data2,2)),'--k','LineWidth',1);
    %legend('Normal', 'Block9Hz');
    hold off
    title(['Freq: ' num2str(index(freq(q))) ' ,corr= ' ...
        num2str(corr2(temp(freq(q),1:gap:size(data1,2)),...
        temp2(freq(q),1:gap:size(data2,2))))]);
    %ylim([0 0.6]);
end
end

