![如何使用 caption/subcaption 包为包含三个子图的图形编写单个图例](https://linux22.com/image/341423/%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8%20caption%2Fsubcaption%20%E5%8C%85%E4%B8%BA%E5%8C%85%E5%90%AB%E4%B8%89%E4%B8%AA%E5%AD%90%E5%9B%BE%E7%9A%84%E5%9B%BE%E5%BD%A2%E7%BC%96%E5%86%99%E5%8D%95%E4%B8%AA%E5%9B%BE%E4%BE%8B%20.png)
我想为包含散点图的三个子图创建一个图例。图例应位于整体图下方的中央。有人能帮忙吗?
下面是骨架:
\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}