%% Figure 1 - show weak correlation between height change during summiting and summity-ness

load('Data\Fig 1 + Supp\Cs_all_standard.mat');
outDir = uigetdir('Select output directory');

%% 
pixelToMm = speedToMmPerS;
scaleFactor = pixelToMm * 3;
 
figure;
hold on;

xRange = min(summit.sumInt):0.01:max(summit.sumInt);

rVal = corrcoef(summit.sumInt,summit.sumHt);
coeff = polyfit(summit.sumInt,summit.sumHt, 1); % first coefficient is slope, second is intercept. This is also given by fitlm, but a bit harder to get to

scatter(summit.sumInt*scaleFactor,summit.sumHt,20,'MarkerFaceColor','r','MarkerEdgeColor','none','MarkerFaceAlpha',0.5,'jitter','on','jitterAmount',0.1)
plot(xRange, (xRange*coeff(1))+coeff(2));
text(-0.4,0.9,num2str(rVal(1,2)));
plot(xRange,zeros(1,length(xRange)),'k')
xlim([-0.5 1]);
ylim([-1 1]);

xlabel('Summit metric');
ylabel('Relative y position change');
set(gca,'TickLength',[0 0]);

set(gcf,'PaperUnits','inches','PaperPosition',[0 0 4 4]);
print(strcat(outDir,'Cs WF_sumHt vs SM'),'-dpdf');
close();
