如何使用 caption/subcaption 包为包含三个子图的图形编写单个图例

如何使用 caption/subcaption 包为包含三个子图的图形编写单个图例

我想为包含散点图的三个子图创建一个图例。图例应位于整体图下方的中央。有人能帮忙吗?

下面是骨架:

\begin{figure}[H] %[htbp]
\centering

\begin{subfigure}[t]{0.45\textwidth}
\centering
\begin{tikzpicture}
 \begin{axis}[%
      scale=0.7,
      xmin = 0, xmax = a,
      xtick={...},
      xlabel={...},
      xmajorgrids,
      ymin = 0, ymax = b,
      ytick={},
      ylabel={...},      
      ymajorgrids,
      axis background/.style={fill=white},
      legend style={legend cell align=left,draw=black,at={(0.5,-0.25)},anchor=north},
      scatter/classes={%
        REF1={color=black,mark size=2.0pt,only marks,mark=o,mark options={solid}}}]      
    \addplot [name path=high,color=black,dashed,line width=0.5pt] table [col sep=comma,x index=0,y index=1]{img/high.txt};
    \addplot [color=black,solid,line width=0.5pt] table [col sep=comma,x index=0,y index=1]{img/mid.txt};
    \addplot [name path=low,color=black,dotted,line width=0.5pt] table [col sep=comma,x index=0,y index=1]{img/low.txt};    
    \addplot [scatter,only marks,%
      scatter src=explicit symbolic]%
    table[col sep=comma,meta=label,x index=0,y index=1] {img/REF1.txt};
    \addplot [fill=gray,opacity=0.20] fill between[of=high and low];
    \legend{high_leg,mid_leg,low_leg,\cite{REF1}}    
  \end{axis}
\end{tikzpicture}
\caption{...\label{fig:fig1a}}
\end{subfigure}%
\hfill
\begin{subfigure}[t]{0.45\textwidth}
\centering
\begin{tikzpicture}
 \begin{axis}[%
      scale=0.7,
      xmin = 0, xmax = a,
      xtick={...},
      xlabel={...},
      xmajorgrids,
      ymin = 0, ymax = b,
      ytick={},
      ylabel={...},      
      ymajorgrids,
      axis background/.style={fill=white},
      legend style={legend cell align=left,draw=black,at={(0.5,-0.25)},anchor=north},     
      scatter/classes={%
   REF2={color=black,mark size=2.0pt,only marks,mark=Mercedes star,mark options={solid}}}]
    \addplot [name path=high,color=black,dashed,line width=0.5pt] table [col sep=comma,x index=0,y index=1]{img/high.txt};
    \addplot [color=black,solid,line width=0.5pt] table [col sep=comma,x index=0,y index=1]{img/mid.txt};
    \addplot [name path=low,color=black,dotted,line width=0.5pt] table [col sep=comma,x index=0,y index=1]{img/low.txt};    
    \addplot [scatter,only marks,%
      scatter src=explicit symbolic]%
    table[col sep=comma,meta=label,x index=0,y index=1] {img/REF2.txt};
    \addplot [fill=gray,opacity=0.20] fill between[of=high and low];
    \legend{high_leg,mid_leg,low_leg,\cite{REF2}}    
  \end{axis}
\end{tikzpicture}
\caption{...\label{fig:fig1b}}
\end{subfigure}\\
\vspace{0.5cm}
\begin{subfigure}[t]{0.45\textwidth}
\centering
\begin{tikzpicture}
 \begin{axis}[%
      scale=0.7,
      xmin = 0, xmax = a,
      xtick={...},
      xlabel={...},
      xmajorgrids,
      ymin = 0, ymax = b,
      ytick={},
      ylabel={...},      
      ymajorgrids,
      axis background/.style={fill=white},
      legend style={legend cell align=left,draw=black,at={(0.5,-0.25)},anchor=north},
      scatter/classes={%
   REF2_full={color=black,mark size=2.0pt,only marks,mark=o,mark options={solid}}}]
    \addplot [name path=high,color=black,dashed,line width=0.5pt] table [col sep=comma,x index=0,y index=1]{img/high.txt};
    \addplot [color=black,solid,line width=0.5pt] table [col sep=comma,x index=0,y index=1]{img/mid.txt};
    \addplot [name path=low,color=black,dotted,line width=0.5pt] table [col sep=comma,x index=0,y index=1]{img/low.txt};    
    \addplot [scatter,only marks,%
      scatter src=explicit symbolic]%
    table[col sep=comma,meta=label,x index=0,y index=1] {img/REF2_full.txt};
    \addplot [fill=gray,opacity=0.20] fill between[of=high and low];
    \legend{high_leg,mid_leg,low_leg,\cite{REF1}}    
  \end{axis}
\end{tikzpicture}
\caption{...\label{fig:fig1c}}
\end{subfigure}

\caption{...\label{fig:fig1}}
\end{figure}

相关内容