从 pgfplots groupstyle 中拆分子图

从 pgfplots groupstyle 中拆分子图

在下面的代码中,我想知道在 groupplot 中拆分图形的最佳方法是什么?我想将图 (a) 和 (b) 放在第 1 页的正文下方,其余图形放在另一页。你能告诉我如何做到这一点吗?谢谢。

这是我的代码:

\documentclass[11pt]{book}
\usepackage[top=3cm,bottom=3cm,left=3.2cm,right=3.2cm,headsep=10pt,a4paper]{geometry}
\usepackage{lipsum}
\usepackage{subfigure}
\usepackage{tikz}
\usepackage{float}
\usepackage{pgfplots,pgfplotstable, booktabs}
\usetikzlibrary{pgfplots.groupplots, matrix}
\pgfplotsset{compat=1.12}

\pgfplotsset{minor grid style={dashed,red}}
\pgfplotsset{major grid style={dotted,green!50!black}}

\begin{document}
\lipsum[1-3]
\begin{figure}
\centering
\begin{tikzpicture}
\begin{groupplot}[group style={
                              group size=2 by 3,
                              vertical sep=2cm,
                              horizontal sep = 2cm,
                              ylabels at=edge left},
                              width=7cm,
                              height=6cm,
                              try min ticks=5,
                              ]
\nextgroupplot[title = {\emph{(a) Plot 1}}, xlabel={Frequency (Hz)}, grid=both, every major grid/.style={gray, opacity=0.5}]
\addplot[smooth,blue]{rnd};

\nextgroupplot[title = {\emph{(b) Plot 2}}, xlabel={Frequency (Hz)}, grid=both, every major grid/.style={gray, opacity=0.5}]
\addplot[smooth,blue] {rnd};
\addplot[mark=*,red,mark options={scale=.65}] {rnd};

\nextgroupplot[title = {\emph{(c) Plot 3}}, xlabel={Frequency (Hz)}, grid=both, every major grid/.style={gray, opacity=0.5}]
\addplot[smooth,blue] {rnd};

\nextgroupplot[title = {\emph{(d) Plot 4}}, xlabel={Frequency (Hz)}, grid=both, every major grid/.style={gray, opacity=0.5}]
\addplot[smooth,blue] {rnd};
\addplot[mark=*,red,mark options={scale=.65}] {rnd};

\nextgroupplot[title = {\emph{(e) Plot 5}}, xlabel={Frequency (Hz)}, grid=both, every major grid/.style={gray, opacity=0.5}]
\addplot[smooth,blue] {rnd};

\nextgroupplot[title = {\emph{(f) Plot 6}}, xlabel={Frequency (Hz)}, grid=both, every major grid/.style={gray, opacity=0.5}]
\addplot[smooth,blue] {rnd};
\addplot[mark=*,red,mark options={scale=.65}] {rnd};

\end{groupplot}

\end{tikzpicture}
\caption[Plot showing Absolute Errors.]{Plot showing Absolute Errors.}\label{abserror}
\end{figure}

\end{document} 

答案1

根据 Joe 的要求:这是从 LaRiFaRis 答案中获取的代码,但用 、 和 替换了反魔法(以及 的未记录用法\captionof{subfigure}):\ContinuedFloat\setcaptionsubtype\caption

(注意:如果 LaRiFaRi 相应地编辑了他的/她的答案,则可以删除该答案。)

% arara: pdflatex
% arara: pdflatex

\documentclass[11pt]{book}
\usepackage[%
    ,top=3cm
    ,bottom=3cm
    ,left=3.2cm
    ,right=3.2cm
    ,headsep=10pt
    ,a4paper
    ]{geometry}
\usepackage{lipsum}
\usepackage{pgfplots}
\usepgfplotslibrary{groupplots}
\pgfplotsset{%
    ,compat=1.12
    ,minor grid style={dashed,red}
    ,major grid style={dotted,green!50!black}
    }
\usepackage{caption,subcaption}
\captionsetup[subfigure]{labelfont=it,textfont=it,labelformat=parens,labelsep=space}
\usepackage{siunitx}

\begin{document}
\listoffigures
\lipsum[1]
\begin{figure}[h]
    \centering
    \begin{tikzpicture}
        \setcaptionsubtype
        \begin{groupplot}[%
            ,group style={%
                ,group name=my plots
                ,group size=2 by 3
                ,vertical sep=2cm,
                ,horizontal sep = 2cm,
                ,ylabels at=edge left
                }
            ,width=7cm
            ,height=6cm
            ,try min ticks=5
            ,xlabel={Frequency in \si{\hertz}}
            ,grid=both
            ,every major grid/.style={gray, opacity=0.5}
            ]
            \nextgroupplot%
                \addplot[smooth,blue]{rnd};     
            \nextgroupplot%
                \addplot[smooth,blue] {rnd};%
                \addplot[mark=*,red,mark options={scale=.65}] {rnd};    
        \end{groupplot}
        \node[text width=.5\linewidth,align=center,anchor=south] at (my plots c1r1.north) {\caption{Plot \arabic{subfigure}\label{subplot:one}}};
        \node[text width=.5\linewidth,align=center,anchor=south] at (my plots c2r1.north) {\caption{Plot \arabic{subfigure}\label{subplot:two}}};    
    \end{tikzpicture}
    \caption{Plot showing Absolute Errors.}
\end{figure}
\begin{figure}
    \ContinuedFloat
    \centering
    \begin{tikzpicture}
        \setcaptionsubtype
        \begin{groupplot}[%
            ,group style={%
                ,group name=my plots
                ,group size=2 by 3
                ,vertical sep=2cm,
                ,horizontal sep = 2cm,
                ,ylabels at=edge left
            }
            ,width=7cm
            ,height=6cm
            ,try min ticks=5
            ,xlabel={Frequency in \si{\hertz}}
            ,grid=both
            ,every major grid/.style={gray, opacity=0.5}
            ]   
            \nextgroupplot%
                \addplot[smooth,blue] {rnd};        
            \nextgroupplot%
                \addplot[smooth,blue] {rnd};%
                \addplot[mark=*,red,mark options={scale=.65}] {rnd};        
            \nextgroupplot%
                \addplot[smooth,blue] {rnd};        
            \nextgroupplot%
                \addplot[smooth,blue] {rnd};%
                \addplot[mark=*,red,mark options={scale=.65}] {rnd};        
        \end{groupplot} 
        \node[text width=.5\linewidth,align=center,anchor=south] at (my plots c1r1.north) {\caption[]{Plot \arabic{subfigure}\label{subplot:three}}};
        \node[text width=.5\linewidth,align=center,anchor=south] at (my plots c2r1.north) {\caption[]{Plot \arabic{subfigure}\label{subplot:four}}};
        \node[text width=.5\linewidth,align=center,anchor=south] at (my plots c1r2.north) {\caption[]{Plot \arabic{subfigure}\label{subplot:five}}};
        \node[text width=.5\linewidth,align=center,anchor=south] at (my plots c2r2.north) {\caption[]{Plot \arabic{subfigure}\label{subplot:six}}};    
    \end{tikzpicture}
    \caption[]{Plot showing Absolute Errors. (continued)}\label{abserror}
\end{figure}
\end{document}

相关内容