I am trying to make a figure with subfigures containing plots made with asymptotic functions and pgfplots. As one may see, the sizes of subfigures are different. I wish to make all the subfigures of the same size and also to make them align vertically and horizontally with each other.
Aligning them would mean, the y labels of plot 2 and plot 4 to come in line. The x labels of plot 1 and plot 2 are to come in line.
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}
%\addtokomafont{caption}{\scriptsize}
\setkomafont{captionlabel}{\bfseries\rmfamily}
%\addtokomafont{caption}{\scriptsize}
\usepackage[dvipsnames,table,xcdraw]{xcolor}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usepackage[inline]{asymptote}
%import graph;
%\usepackage[paper=a4paper,hmargin=2cm,vmargin=2.5cm]{geometry}
%\usepackage{parskip}
%\setlength{\columnsep}{3em}
%\title{Asymptote 3D graphics}
\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.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
144 0.11587881 a
};
\end{loglogaxis}
\end{tikzpicture}
\caption{Plot 1}
\end{subfigure}
\hfill
\begin{subfigure}[t]{0.48\linewidth}
%\begin{tikzpicture}
%\begin{axis}[
% %domain=0:25,
% ymin= -3e-2, ymax= 3e-2,
% xmin=1, xmax=2,
% xlabel={Input $x$},
% ylabel={$f(x)$} ]
\begin{asy}
import graph;
size(7.5cm,8cm,IgnoreAspect);
real xmin=1,xmax=2, ymin=-.03,ymax=.03;
pair f(real x){return (x,Jn(0,170x)*cos(100x)/(x^2+1));}
guide gf=graph(f,xmin,xmax,n=1000);
(draw(gf,orange));
pair f(real x){return (x,Jn(0,90x)*cos(100x)/(x^2+1));}
guide gf2=graph(f,xmin,xmax,n=1000);
(draw(gf2,black));
label("$F(x)=\dfrac{\cos(100x)}{x^2+1}J_0(170x)$",(2,.02),2W); xaxis("Input",BottomTop,LeftTicks); yaxis("$f(x)$",LeftRight,RightTicks);
\end{asy}
%\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-7, 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
320 0.608216725 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 {e^x)};
% \addplot {e^(2*x))};
% \legend{$\exp(x)$,$\exp(2x)$}
% \end{axis}
%\end{tikzpicture}
\begin{tikzpicture}
\begin{axis}[%domain=0:1,
xlabel={Input $x$},
ylabel={$f(x)$},
ymin= -1e1, ymax=1e1 ]
\addplot[orange,samples=500,domain=0:1.5]plot (\x, {exp(\x)*sin(100*cosh(\x) r)});
\addplot[orange,samples=1000,domain=1.5:2]plot (\x, {exp(\x)*sin(100*cosh(\x) r)});
%\legend{\textcolor{orange}{$\mathrm e^x\sin\left(100\cosh\left(x\right)\right)$}}
\addplot[black,samples=500,domain=0:1.5]plot (\x, {exp(\x)*sin(10*cosh(\x) r)});
\addplot[black,samples=1000,domain=1.5:2]plot (\x, {exp(\x)*sin(10*cosh(\x) r)});
\legend{\textcolor{black}{$\mathrm e^x\sin\left(100\cosh\left(x\right)\right)$}, \textcolor{black}{$\mathrm e^x\sin\left(10\cosh\left(x\right)\right)$}}
\end{axis}
\end{tikzpicture}
\caption{Plot 4}
\end{subfigure}
\caption{caption for all plots}
\label{all_plots}
\end{figure}
\end{document}



groupplotoption. You can find it in the PGF manual. – DraUX Aug 15 '23 at 17:31\usepgfplotslibrary{groupplots}in your preamble – DraUX Aug 18 '23 at 16:58\begin{tikzpicture}but I am currently having 4; also how to place the\begin{loglogaxis}[] ...inside the grouplot ? – Formal_this Aug 18 '23 at 17:10