clear; clc; close all;

load("data.mat");
confirmed = zeros(size(raw_data, 1) - 1, 1);
for i = 1 : length(confirmed)
    confirmed(i) = str2num(raw_data{i + 1, 2});
end
regions = string(raw_data(2 : end, 15));
regions = unique(regions);

tbl = zeros(length(regions), 1);
for i = 1 : length(regions)
    mask = regions(i) == raw_data(2 : end, 15);
    tbl(i) = sum(confirmed(mask));
end  
[tbl, idx] = sort(tbl);
regions = regions(idx);

figure;
pie(tbl);
legend(regions, "location", "eastoutside");

print(gcf, "-djpeg", "output.jpeg", "-r300");
