%% 2022-11-21 Generic scatter script

% Load struct containing summit integrations for tall wells data (0
% degrees, 30 degrees)

baseDir = "D:\Harvard\Summit behavior\Analysis\Screen\Boxes v3\Summit quantification\2022-11-17-tall wells\";
load(strcat(baseDir,"2022-11-17_combinedSummit.mat"));

%% Prepare data for plotting
idxs = [1,2];
[sumVal, boxLabel, scatterX, medVal, stdVal] = prepareBoxScatterv2(combinedSummit,idxs);

gLabels = combinedSummit.geno; 

width = 40;
height = 34;
speedConv = speedToMmPerS;
scaleFactor = speedConv * 3;

% Plot data and save
f = figure('Units','Pixels','Position',[0 0 (width*5 +200) (height*5 + 200)]);
axesH = axes;
set(axesH,'Units','pixels','Position',[50,50,width*5,height*5]);
hold on;

% Prepare labels for x axis (takes in summit struct)
labels = gLabels;

colorScheme = repmat('k',1,length(labels));  % All in black
   
% % Plot scatter with overlaid median +/- stdev
s = scatter(scatterX,sumVal*scaleFactor,20,'MarkerFaceColor','r','MarkerEdgeColor','none','MarkerFaceAlpha',0.5,'jitter','on','jitterAmount',0.1);
erX = 1:length(medVal);

for i=1:length(medVal)
    xRange = i-0.1:0.1:i+0.1;
    plot(xRange,repmat(medVal(i)*scaleFactor,1,length(xRange)),'Color',[0 0 0],'LineWidth',1.5')
end

% % Set labels etc
set(gca,'xtick',1:numel(idxs),'xticklabel',labels);
axesH.TickLength = [0 0];
xtickangle(45);
xlim([0.5 max(idxs)+0.5])
ylabel('Summit metric');
ylim([-0.5 1]);

print(strcat(baseDir,'out_scatter.pdf'),'-dpdf');
close();
