%Read and Plot Stats of Weimer05 and IDM F13 maxVy locs and mags
close all

date_title = sprintf('Weimer05 and DMSP-F13 Comparisons of Sunward Max Vy');

file = sprintf('/home/emery/reu11/3y_good_stats_tbl');
STAT = fopen(file,'r');
% Skip over 22 lines
for i=1:22
 line = fgetl(STAT);
end
% Read total stats for W05 and F13 IDM
clear y;
%face_gcrb = [0 0.5 0  0 1 0  0.57 0.49 0  0 0 1];

 line = fgetl(STAT);
 statdat = sscanf(line,'%f %f %f %f %f %s %s %s');
 totnum = statdat(1);
 pcgood = statdat(2);
 pcgdmagofgood = statdat(3)*0.01;
 pcgdmag = statdat(2)*statdat(3)*0.01*0.01;
 pcbadmag = statdat(2)*0.01 - pcgdmag;
 pcwpol = statdat(4)*0.01;
 pcwequ = statdat(5)*0.01;
 y(1) = pcgdmag;
 y(2) = pcbadmag;
 y(3) = pcwequ;
 y(4) = pcwpol;

y

h = pie (y);
colormap jet;		% This was ignored
title(date_title,'fontsize',15,'fontweight','bold');

% Code below exchanged % titles
textObjs = findobj(h,'Type','text');
oldStr = get(textObjs,{'String'});
val = get(textObjs,{'Extent'});
oldExt = cat(1,val{:});
Names = {'Good loc/mag: ';'Good loc/Bad mag: '; 'W05 eqwds: ';'W05 polewards of F13: '};
newStr = strcat(Names,oldStr);
set (textObjs,{'String'},newStr)

%  Code below to reposition
val1 = get(textObjs, {'Extent'});
newExt = cat(1,val1{:});
offset = sign(oldExt(:,1)).*(newExt(:,3)-oldExt(:,3))/2;
pos = get(textObjs, {'Position'});
textPos = cat(1,pos{:});
textPos(:,1) = textPos(:,1)+offset;
%%textPos(1,1) = textPos(1,1)+offset(1);
set(textObjs,{'Position'},num2cell(textPos,[3,2]),'fontsize',12,'fontweight','bold')
set(gca,'fontsize',12,'fontweight','bold');


