G = 24*1e9; %[pa]
% Maximum moment magnitude
McGarrV = 10.^([-10:10]);
McGarrM10 = McGarrV*G*0.11/0.99*0.5;  %10%
McGarrM50 = McGarrV*G*0.5;  %50%
McGarrM90 = McGarrV*G*0.9/0.1*0.5;  %90%
McGarrM99 = McGarrV*G*0.999/0.001*0.5;  %99%

%%
T = readtable('Literature data.xlsx','Range','B1:C47');

V_1 = table2array([T(1,1);T(14:23,1);T(30:31,1)]);
M_1 = table2array([T(1,2);T(14:23,2);T(30:31,2)]);  % fracking
V_2 = table2array([T(2:4,1);T(24:28,1);T(32:34,1)]);
M_2 = table2array([T(2:4,2);T(24:28,2);T(32:34,2)]);  % egs
V_3 = table2array([T(7:13,1);T(35:46,1)]);
M_3 = table2array([T(7:13,2);T(35:46,2)]);  % waste water disposal
V_4 = table2array([T(6,1);T(29,1)]);
M_4 = table2array([T(6,2);T(29,2)]);  % scientific study

h = figure(1);
h(2) = loglog(McGarrV,McGarrM10,'k-.','LineWidth',1);
hold all
h(3) = loglog(McGarrV,McGarrM90,'k-.','LineWidth',1);
h(4) = loglog(McGarrV,McGarrM99,'k-.','LineWidth',1);
h(5) = loglog(V_1,M_1,'d','MarkerEdgeColor','k','MarkerFaceColor',[0.8500 0.3250 0.0980], 'MarkerSize',7);
h(6) = loglog(V_2,M_2,'<','MarkerEdgeColor','k','MarkerFaceColor',[0 0.4470 0.7410], 'MarkerSize',7);
h(7) = loglog(V_3,M_3,'s','MarkerEdgeColor','k','MarkerFaceColor',[0.3010 0.7450 0.9330], 'MarkerSize',7);
h(8) = loglog(V_4,M_4,'>','MarkerEdgeColor','k','MarkerFaceColor',[0.4940 0.1840 0.5560], 'MarkerSize',7);

ax = gca;
ax.FontSize = 11;
set(gca, 'FontName', 'Arial');
ax.LineWidth = 1;
xlabel('Total injection volume [m^3]');
ylabel('Maximum seismic moment [N*m]');
xlim([10^-10,10^10]);
ylim([10^-5,10^21]);
legend boxoff;

% Yu et al., 2023
h(9) = text(10^(-5),10^(9), '99.9%', 'Color','k', 'FontSize', 11);
h(10) = text(10^(-5),10^(7),'90%', 'Color','k', 'FontSize', 11);
h(11) = text(10^(-5),10^(5),'10%', 'Color','k', 'FontSize', 11);
set(h(9:11),'Rotation',33);
h(12) = text(10^(1.6),10^(19.2), {'Mx 5.5', 'Pohang'}, 'Color','k', 'FontSize', 11);

% Galis et al., 2017
h(13)= loglog(McGarrV,McGarrV.^(3/2)*1.5e10,'--.','color',[.7 .7 .7],'LineWidth',1);
h(14)= loglog(McGarrV,McGarrV.^(3/2)*1.5e6,'--.','color',[.7 .7 .7],'LineWidth',1);
h(15) = text(10^(-7),10^(-2), 'M_x={\gamma}{\Delta}V^{3/2},{\gamma}=1.5e6', 'Color',[.7 .7 .7], 'FontSize', 10);
h(16) = text(10^(-4.4),10^(-2), 'M_x={\gamma}{\Delta}V^{3/2},{\gamma}=1.5e10', 'Color',[.7 .7 .7], 'FontSize', 10);
set(h(15:16),'Rotation',45);

legend([h(5:8),h(13)],'Hydraulic fracturing','Enhenced Geothermal','Waste Water Disposal','Scientific Study','Galis et al., 2017','location','northwest','FontSize', 11);
