I am trying to plot the following figure with 4 sub-plots. The first figure shows the kind of plot which I want to get corrected. The corrections are marked with questions. I tried an answer from a previous post, and the code is shown below.
The result of which is shown in the result section. But the problem with alignment of sub-figures and labels still persist. Can someone suggest the changes in my code, which can result in a better and meaningful figure.
Correction required:
Result:
Code:
\documentclass[12pt, a4paper,
parskip=half,
toc=bibliography,
numbers=noendperiod
]{scrbook}
\usepackage[hmargin={3.0cm, 2.5cm},
vmargin={2.5cm, 2.0cm},
includehead, includefoot
]{geometry}
\usepackage[UKenglish]{babel}
\usepackage[T1]{fontenc}
\usepackage{scrlayer-scrpage}
\usepackage{subcaption}
\usepackage{caption}
\addtokomafont{caption}{\scriptsize}
\setkomafont{captionlabel}{\bfseries\rmfamily}
\usepackage[dvipsnames,table,xcdraw]{xcolor}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{figure}[ht]
\pgfplotsset{
width=\linewidth, height=0.75\linewidth,
enlarge y limits=0.1,
%tick label style={font=\scriptsize},
%xticklabel style = {text width=0.4em},
%ylabel style = {text width=1em, inner sep=2pt},
%yticklabel style = {text width=0.2em},
%label style={font=\bfseries\boldmath},
%tick label style={font=\bfseries\boldmath},
%
%tick align = outside,
%tick pos = left,
%every axis plot post/.append style={color=Blue, dashed, mark=},
}
\begin{subfigure}[t]{0.48\linewidth}
\begin{tikzpicture}
\begin{loglogaxis}[
xmin=0.1, xmax=0.1e8,
ymin=1e-8, ymax=5e3,
xlabel={Number of Flops},
ylabel={Normalized MSE: $\log_{10} (e)$ },
scatter/classes={ a={mark=square, blue}, b={mark=square, red}, c={mark=square, black}, d={mark=triangle, blue}, e={mark=triangle, red},f={mark=triangle, black},g={mark=x, black}, h={mark= diamond, pink} },
]
\addplot[scatter, only marks,
scatter src=explicit symbolic]
table[meta=label] {
x y label
1320.9279232530525 0.9258769833615981 a
3102.831857215906 0.7072210955836371 a
};
\end{loglogaxis}
\end{tikzpicture}
\caption{Plot 1}
\end{subfigure}
\hfill
\begin{subfigure}[t]{0.48\linewidth}
\begin{tikzpicture}
\begin{axis}[
domain=0:1,
ymax=1,
xlabel={Input $x$},
ylabel={$f(x)$},
%samples=801
]
\addplot {sin(5deg(x))};
\addplot {sin(10*deg(x))};
\legend{$\sin(5x)$,$\sin(10x)$,$\sin(50x)$}
\end{axis}
\end{tikzpicture}
\caption{Plot 2}
\end{subfigure}
\medskip
\begin{subfigure}[t]{0.48\linewidth}
\begin{tikzpicture}
\begin{loglogaxis}[
xmin=0.1, xmax=0.1e8,
ymin=1e-13, ymax=5e3,
xlabel={Number of Flops},
ylabel={Normalized MSE: $\log_{10} (e)$ },
%label style={font=\bfseries\boldmath},
%tick label style={font=\bfseries\boldmath},
scatter/classes={ a={mark=square*, blue}, b={mark=square*, red}, c={mark=square, black}, d={mark=triangle*, blue}, e={mark=triangle*, red},f={mark=triangle*, black},g={mark=x, black}, h={mark= diamond*, pink} },
]
\addplot[scatter, only marks,
scatter src=explicit symbolic]
table[meta=label] {
x y label
55.57063517556737 0.28272347338878956 a
285.8811806506138 0.003443221651312178 a
};
\end{loglogaxis}
\end{tikzpicture}
\caption{Plot 3}
\end{subfigure}
\hfill
\begin{subfigure}[t]{0.48\linewidth}
\begin{tikzpicture}
\begin{axis}[
xlabel={Input $x$},
ylabel={$f(x)$},
ymin= 0, ymax=1e2,
]
\addplot {e^x)};
\addplot {e^(2*x))};
\legend{$\exp(x)$,$\exp(2x)$}
\end{axis}
\end{tikzpicture}
\caption{Plot 4}
\end{subfigure}
\caption{caption for all plots}
\label{all_plots}
\end{figure}
\end{document}
New updates:
Updated figure
Updated code:
\documentclass[12pt, a4paper,
parskip=half,
toc=bibliography,
numbers=noendperiod
]{scrbook}
\usepackage[hmargin={3.0cm, 2.5cm},
vmargin={2.5cm, 2.0cm},
includehead, includefoot
]{geometry}
\usepackage[UKenglish]{babel}
\usepackage[T1]{fontenc}
\usepackage{scrlayer-scrpage}
\usepackage{subcaption}
\usepackage{caption}
\setkomafont{captionlabel}{\bfseries\rmfamily}
\usepackage[dvipsnames,table,xcdraw]{xcolor}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usepackage[font=normalsize]{subcaption}
\begin{document}
\begin{figure}[ht]
\pgfplotsset{
width=\linewidth, height=0.9\linewidth,
enlarge y limits=0.1,
%tick label style={font=\scriptsize},
xticklabel style = {text width=0.8em},
%ylabel style = {text width=1em, inner sep=2pt},
yticklabel style = {text width=2.0em, anchor= east},
label style={font=\bfseries\boldmath},
%tick label style={font=\bfseries\boldmath},
%
%tick align = outside,
tick pos = left,
%every axis plot post/.append style={color=Blue, dashed, mark=},
}
\begin{subfigure}[t]{0.48\linewidth}
\begin{tikzpicture}
\begin{loglogaxis}[
xmin=10, xmax=0.1e8,
ymin=1e-8, ymax=1e2,
xlabel={Number of Flops},
ylabel={Normalized MSE: $\log_{10} (e)$ },
scatter/classes={ a={mark=square, blue}, b={mark=square, red}, c={mark=square, black}, d={mark=triangle, blue}, e={mark=triangle, red},f={mark=triangle, black},g={mark=x, black}, h={mark= diamond*, pink} },
]
\addplot[scatter, only marks,
scatter src=explicit symbolic]
table[meta=label] {
x y label
1320.9279232530525 0.9258769833615981 a
};
\end{loglogaxis}
\end{tikzpicture}
\caption{Plot 1}
\end{subfigure}
\hfill
\begin{subfigure}[t]{0.48\linewidth}
\begin{tikzpicture}
\begin{axis}[
domain=0:1,
ymax=1,
xlabel={Input $x$},
ylabel={$f(x)$},
%samples=801
]
\addplot[orange, mark=*] {sin(5*deg(x))};
\addplot[black, mark=*] {sin(10*deg(x))};
\legend{$\sin(5x)$,$\sin(10x)$,$\sin(50x)$}
\end{axis}
\end{tikzpicture}
\caption{Plot 2}
\end{subfigure}
\medskip
\begin{subfigure}[t]{0.48\linewidth}
\begin{tikzpicture}
\begin{loglogaxis}[
xmin=10, xmax=0.1e8,
ymin=1e-13, ymax=1e1,
xlabel={Number of Flops},
ylabel={Normalized MSE: $\log_{10} (e)$ },
%label style={font=\bfseries\boldmath},
%tick label style={font=\bfseries\boldmath},
scatter/classes={ a={mark=square*, blue}, b={mark=square*, red}, c={mark=square, black}, d={mark=triangle*, blue}, e={mark=triangle*, red},f={mark=triangle*, black},g={mark=x, black}, h={mark= diamond*, pink} },
]
\addplot[scatter, only marks,
scatter src=explicit symbolic]
table[meta=label] {
x y label
55.57063517556737 0.28272347338878956 a
};
\end{loglogaxis}
\end{tikzpicture}
\caption{Plot 3}
\end{subfigure}
\hfill
\begin{subfigure}[t]{0.48\linewidth}
\begin{tikzpicture}
\begin{axis}[
domain=0:1,
xlabel={Input $x$},
ylabel={$f(x)$},
ymin= 0, ymax=1e1,
]
\addplot[orange, mark=*] {e^x)};
\addplot[black, mark=*] {e^(2*x))};
\legend{$\exp(x)$,$\exp(2x)$}
\end{axis}
\end{tikzpicture}
\caption{Plot 4}
\end{subfigure}
\caption{caption for all plots}
\label{all_plots}
\end{figure}
\end{document}


