如何将多个图形排列为页面上的子图形

如何将多个图形排列为页面上的子图形

我的页面上有多个图形,根据之前的帖子,我曾尝试一次排列 2 个图形。我希望让所有 4 个图形都显示为 1 个,并带有子标签 (a)、(b)、(c)、(d),这些子标签彼此之间都正确对齐。

代码:此代码有 2 个数字,其中包含 2 个数字。

\begin{figure}[t]
\centering
\begin{minipage}{.45\linewidth}
  \pgfplotsset{every axis/.append style={scale=0.8}}
  \input{figs/FIG_5.tikz}
  \captionof{figure}{First caption}
  \label{fig:LV}
\end{minipage}\hfill
\begin{minipage}{.45\linewidth}
  \pgfplotsset{every axis/.append style={scale=0.8}}
  \input{figs/Fig12.tikz}
  \captionof{figure}{Second caption}
  \label{fig:LV2}
\end{minipage}
\end{figure}

\begin{figure}[t]
    \centering
    \begin{minipage}{0.45\textwidth}
        \centering
        \pgfplotsset{every axis/.append style={scale=0.8}}
        %\graphicspath{figs/FIG_3.tikz}
         \input{figs/FIG_3.tikz} % first figure itself
        \caption{first figure}
        \label{fig:EW}
    \end{minipage}\hfill
    \begin{minipage}{0.45\textwidth}
        \centering
        \pgfplotsset{every axis/.append style={scale=0.8}}
         \input{figs/Fig11.tikz} % second figure itself
        \caption{second figure}
        \label{fig:EW2}
    \end{minipage}
\end{figure}

代码图5和图3:

\documentclass{article}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}

\pgfplotsset{
  set layers,% using layers
  mark layer=axis tick labels,% defines the layer of the marks
  every axis/.append style={scale=1.2}
}

\begin{semilogyaxis}[
xmin=0, xmax=205,
ymin=1e-1, ymax=1e5,
xlabel={Oscilatoriness parameter ($k$)}, 
ylabel={Gain in performance ($\alpha$)},
label style={font=\bfseries\boldmath},
tick label style={font=\bfseries\boldmath},
legend pos=outer north east,
scatter/classes={ a={mark=square*, violet}, a1={mark=square*, red},
] 
\addplot[scatter, only marks,
scatter src=explicit symbolic]
table[meta=label] {
x     y      label

5 5.67E+00 a 
5 6.67E-01 a1

};
\end{semilogyaxis}

\end{tikzpicture}
\end{document}

代码 :图11:

\begin{tikzpicture}
\begin{axis}[axis x line=middle,axis y line=left,xlabel=$x$,restrict y to domain =-9:9, legend pos=north west ]
\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[blue,samples=500,domain=0:1.5]plot (\x, {exp(\x)*sin(10*cosh(\x) r)});
\addplot[blue,samples=1000,domain=1.5:2]plot (\x, {exp(\x)*sin(10*cosh(\x) r)});

\legend{\textcolor{orange}{$\mathrm e^x\sin\left(100\cosh\left(x\right)\right)$}, \textcolor{blue}{$\mathrm e^x\sin\left(10\cosh\left(x\right)\right)$}}

\end{axis}
\end{tikzpicture}

图 12:

\begin{pspicture}(0,-.5)(20,1.0)
\rput(13,0.8){%
    $\displaystyle J_n(x)=\frac{1}{\pi}\int_0^\pi\cos(x\sin t-nt)\mathrm{d}t$}
\psaxes[Dy=0.2,Dx=4]{->}(0,0)(0,-.4)(25,1)
\psset{linewidth=1pt}
\psBessel[linecolor=red]{0}{-0}{25}%
\psBessel[linecolor=blue]{1}{-0}{25}%
\psBessel[linecolor=green]{2}{-0}{25}%
\psBessel[linecolor=magenta]{3}{-0}{25}%
\end{pspicture}

在此处输入图片描述

答案1

我没有复制所有图片,只是用一些示例图片替换了它们。不过这应该能满足您的需求。

\documentclass{article}
\usepackage{subcaption,graphicx,pgfplots}

\begin{document}
    \begin{figure}[t]
        \centering
        \subcaptionbox{First caption.\label{fig:LV}}[.45\linewidth]{%
            \pgfplotsset{every axis/.append style={scale=0.8}}%
            %\input{figs/FIG_5.tikz}%
            \includegraphics[width=0.5\linewidth,height=5cm]{example-image-a}%
        }\hfill
        \subcaptionbox{Second caption which goes over multiple lines is also aligned properly.\label{fig:LV2}}[.45\linewidth]{
            \pgfplotsset{every axis/.append style={scale=0.8}}%
            %\input{figs/Fig12.tikz}%
            \includegraphics[width=\linewidth]{example-image-b}%
        }
        \subcaptionbox{Third caption.\label{fig:EW}}[.45\linewidth]{
            \pgfplotsset{every axis/.append style={scale=0.8}}%
            %\graphicspath{figs/FIG_3.tikz}%
            %\input{figs/FIG_3.tikz} % first figure itself
            \includegraphics[width=\linewidth]{example-image-c}%
        }\hfill
        \subcaptionbox{Fourth caption. In every good example there should be a duck!\label{fig:EW2}}[.45\linewidth]{%
            \pgfplotsset{every axis/.append style={scale=0.8}}%
            %\input{figs/Fig11.tikz} % second figure itself
            \includegraphics[width=\linewidth]{example-image-duck}%
        }
        \caption{Collection of all my cool figures.}
    \end{figure}
    References: \ref{fig:LV}, \ref{fig:LV2}, \ref{fig:EW}, \ref{fig:EW2}.
\end{document}

结果

相关内容