clear;
close all;
clc;

% Preparation of figure

N_xticks_m1 = 15;

fig1=figure;
x0=200; y0=45; w0=1305; h0=round(w0)/sqrt(2); set(gcf, 'Position', [x0 y0 w0 h0]);


% Preparation of subplots

x1=0.07;
y1=0.32;
w1=0.7;
h1=1-y1-0.05;

x2=x1+w1+0.04;
y2=y1;

w2=1-x2-0.07;
h2=h1;

x3=x1;
y3=0.08;
w3=w1;
h3=1-y3-h1-0.12;

x4=x2;
y4=y3;
w4=w2;
h4=h3;

subplot1_pos=[x1, y1, w1, h1];  %[left,bottom,width,height]
subplot2_pos=[x2, y2, w2, h2];
subplot3_pos=[x3, y3, w3, h3];
subplot4_pos=[x4, y4, w4, h4];

subplot('Position',subplot1_pos);
subplot('Position',subplot2_pos);
subplot('Position',subplot3_pos);
subplot('Position',subplot4_pos);


%----------------------------------------------------------
subplot('Position',subplot1_pos);

img=100*rand(8997, 31);
imagesc([0:N_xticks_m1], [1:size(img,2)], img',[0, 100]);

F_1_3 = [20; 25; 31.5; 40; 50; 63; 80; 100; 125; 160; 200; 250; 315; 400; 500; 630; 800; 1000; ...
         1250; 1600; 2000; 2500; 3150; 4000; 5000; 6300; 8000; 10000; 12500; 16000; 20000];

ax1=gca;
set(ax1,'YDir', 'normal');
set(ax1, 'YTick', [1:length(F_1_3)]);
set(ax1, 'YTickLabel', F_1_3);


F_1_3b=F_1_3;
idx=find(F_1_3>=1000);

F_1_3b(idx)=F_1_3b(idx)/1000;
F_1_3b_str=cellstr(num2str(F_1_3b));

for count = 1:length(idx)
    F_1_3b_str(idx(count),:)=strcat(F_1_3b_str(idx(count),:), 'k');
end
set(ax1, 'YTickLabel', F_1_3b_str);

ylabel('Ylabel Fig 1')
title('Title Fig 1')

%----------------------------------------------------------

subplot('Position',subplot2_pos)
title('Title Fig 2')

%----------------------------------------------------------

subplot('Position', subplot3_pos)

%----------------------------------------------------------

subplot('Position',subplot4_pos)
title('Title Fig 4')


% Adding some text 

text(1.25 , 0.6, 'Long text',  'FontSize', 8);
text(1.25 , 0.5, 'Text',  'FontSize', 8);
text(1.25 , 0.4, 'Text',  'FontSize', 8);

annotation('textbox', [0.01, 0.00, 0.5, 0.057], 'String', 'Annotation','EdgeColor','none', 'FontSize', 8, 'fitboxtotext', 'off');
annotation('textbox', [0.01, 0.00, 0.5, 0.043], 'String', 'Annotation','EdgeColor','none', 'FontSize', 8, 'fitboxtotext', 'off');
annotation('textbox', [0.01, 0.00, 0.5, 0.029], 'String', 'Annotation','EdgeColor','none', 'FontSize', 8, 'fitboxtotext', 'off');

%----------------------------------------------------------
% Saving image as png or pdf
%----------------------------------------------------------

saveas(fig1, 'file1.png');
saveas(fig1, 'file2.pdf');
print('file3.pdf', '-dpdf');
print('file4.pdf', '-dpdf','-fillpage');
