
clear all

filename0 = 'Fig01';

load('ehtable','whitejet','greyjet','redblue', 'color7');
 
colormap(greyjet)

load Fig01a Ne0 Vg1 Vg2 Vp1 Vp2 npar0 Np01 Np02


%% 

hh=figure(1);
hh.Position = [100 100 500 500];
set(gcf,'color','w');


%%
ii =[ 1:10:90  200 290:20:606]

subplot(1,2,1)

semilogy([1.73e18, 1.73e18],[1e-1, 1e2], '--', 'color', [0.5,0.5,0.5])
hold on
    scatter(Ne0(ii), Np01(ii), 70, (Vg1(ii)), "filled")
    scatter(Ne0(ii), Np02(ii), 70, (Vg2(ii)), "filled")
    plot(Ne0, Np02, 'color', color7(4,:), 'linewidth', 1)
    semilogy(Ne0, Np01, 'color', color7(1,:), 'linewidth', 1) 
hold off

h = colorbar;
set(h, 'location', 'north')
xlabel(h, '\theta_g (degrees)', 'fontsize', 14)

set(gca, 'fontsize', 14) 
set(gca, 'ytick',[1e-1,1e0,1e1,1e2])
set(gca, 'xlim', [0,5e18])
set(gca, 'ylim', [1e-1, 7e2])
set(gca, 'clim', [-5,20])
set(gca, 'linewidth', 1.5)
set(gca, 'position', [0.13, 0.13, 0.35, 0.78])

xlabel('n_{e}', 'fontsize', 18)
ylabel('n_{\perp}', 'fontsize', 18)
title('(a) n_{||} = 3', 'fontsize',17) 
text(3.0e18, 2e0, 'Helicon', 'fontsize', 15, 'color', color7(4,:))
text(3.0e18, 6e1, 'Slow', 'fontsize', 15, 'color', color7(2,:))
text(1.8e18, 1e1, 'n_{FWcut}', 'color', [0.25,0.25,0.25], 'fontsize', 14)

%%

load Fig01b npar0 Np1 Np2 Vg1 Vg2 nparc0 

[~,num01] = min(abs(npar0-2.88));
[~,num02] = min(abs(npar0-4.5));

an  = Vg2(num01)*pi/180;
x01 = [npar0(num01) npar0(num02)];
y00 = [Np2(num01)];
a01 = sin(an);
b01 = y00(1) - x01(1) * a01;
y01 = x01*a01 + b01;

tp1 = [0 0];
tp2 = [x01(1) y01(1)];
dtp = tp2-tp1;
tg1 = [x01(1) y01(1)];
tg2 = [x01(2) y01(2)];
dtg = tg2-tg1;


ii =[1:1500:30000  30000:10:30350]
 
subplot(2,2,2)

semilogy([nparc0, nparc0],[1e-1, 1e3], '--', 'color', [0.5,0.5,0.5])
hold on
scatter(npar0(ii), Np1(ii), 70, (Vg1(ii)), "filled")
scatter(npar0(ii), Np2(ii), 70, (Vg2(ii)), "filled")
plot(npar0, Np1, 'color', color7(1,:), 'linewidth', 1)
plot(npar0, Np2, 'color', color7(4,:), 'linewidth', 1)
hold off

set(gca, 'fontsize', 14)
set(gca, 'ylim', [5, 2e2])
set(gca, 'xlim', [0,5])
set(gca, 'clim', [-5,20])
set(gca, 'xtick','')
set(gca, 'position', [0.62, 0.49, 0.35 0.42])
set(gca, 'linewidth', 1.5)

ylabel('n_{\perp}', 'fontsize', 18)
title('(b) n_{e} = 2.5 \times 10^{18}m^{-3}', 'fontsize',17)
text(2.5, 6e1, 'Slow', 'fontsize', 15, 'color', color7(2,:))
text(0.6, 2e1, 'n_{||c}', 'color', [0.25,0.25,0.25], 'fontsize', 14)


ii =[1:800:30000  30000:5:30350]

subplot(2,2,4)

plot([nparc0, nparc0],[1e-1, 1e3], '--', 'color', [0.5,0.5,0.5])
hold on
scatter(npar0(ii), Np1(ii), 70, (Vg1(ii)), "filled")
scatter(npar0(ii), Np2(ii), 70, (Vg2(ii)), "filled")
    plot(npar0, Np1, 'color', color7(1,:), 'linewidth', 1)
    plot(npar0, Np2, 'color', color7(4,:), 'linewidth', 1)
    quiver(tp1(1),tp1(2),dtp(1),dtp(2),0,'k')
    quiver(tg1(1),tg1(2),dtg(1),dtg(2),0,'k')
    plot([npar0(num01), npar0(num02)],[y01(1), y01(1)], 'k--')
hold off
axis equal
set(gca, 'fontsize', 14)
set(gca, 'ylim', [0, 5])
set(gca, 'xlim', [0,5])
set(gca, 'clim', [-5,20])
set(gca, 'position', [0.62, 0.13, 0.35 0.35])
set(gca, 'linewidth', 1.5)
xlabel('n_{||}', 'fontsize', 18)
ylabel('n_{\perp}', 'fontsize', 18)
text(2.7, 4.5, 'Helicon', 'fontsize', 15, 'color', color7(4,:))
text(3.0, 6e1, 'Slow', 'fontsize', 15, 'color', color7(2,:))
text(4.0, 3.45, '\theta_g', 'fontsize', 13)
text(0.5, 0.35, '\theta_p', 'fontsize', 13)


%%

saveas(gca, filename0,'epsc')
saveas(gca, filename0,'png')


