我有以下代码:
\begin{figure}
\caption{My figure}
\label{evolQAS}
\centering
\begin{tikzpicture}[scale=0.65]
\begin{groupplot}[group style={
group name=myplot,
group size= 2 by 1},height=5cm,width=6.4cm]
\nextgroupplot[title=MAP,xlabel={$\lambda$ values},ylabel={Performance evolution }, label=mapC]
\addplot table [x=lmda,y=1] {inserted/BM25/ap_alpha_map_cB};\label{plots:plot1}
\addplot table [x=lmda,y=2] {inserted/BM25/ap_alpha_map_cB};\label{plots:plot2}
\addplot table [x=lmda,y=3] {inserted/BM25/ap_alpha_map_cB};\label{plots:plot3}
\addplot table [x=lmda,y=4] {inserted/BM25/ap_alpha_map_cB};\label{plots:plot4}
\addplot table [x=lmda,y=5] {inserted/BM25/ap_alpha_map_cB};\label{plots:plot5}
\addplot table [x=lmda,y=6] {inserted/BM25/ap_alpha_map_cB};\label{plots:plot6}
\addplot table [x=lmda,y=7] {inserted/BM25/ap_alpha_map_cB};\label{plots:plot7}
\addplot table [x=lmda,y=8] {inserted/BM25/ap_alpha_map_cB};\label{plots:plot8}
\addplot table [x=lmda,y=9] {inserted/BM25/ap_alpha_map_cB};\label{plots:plot9}
\addplot table [x=lmda,y=10] {inserted/BM25/ap_alpha_map_cB};\label{plots:plot10}
\addplot table [x=lmda,y=11] {inserted/BM25/ap_alpha_map_cB};\label{plots:plot11}
\addplot table [x=lmda,y=12] {inserted/BM25/ap_alpha_map_cB};\label{plots:plot12}
\addplot table [x=lmda,y=13] {inserted/BM25/ap_alpha_map_cB};\label{plots:plot13}
\addplot table [x=lmda,y=14] {inserted/BM25/ap_alpha_map_cB};\label{plots:plot14}
\addplot table [x=lmda,y=15] {inserted/BM25/ap_alpha_map_cB};\label{plots:plot15}
\addplot table [x=lmda,y=16] {inserted/BM25/ap_alpha_map_cB};\label{plots:plot16}
\addplot table [x=lmda,y=17] {inserted/BM25/ap_alpha_map_cB};\label{plots:plot17}
\addplot table [x=lmda,y=18] {inserted/BM25/ap_alpha_map_cB};\label{plots:plot18}
\addplot table [x=lmda,y=19] {inserted/BM25/ap_alpha_map_cB};\label{plots:plot19}
\addplot table [x=lmda,y=20] {inserted/BM25/ap_alpha_map_cB};\label{plots:plot20}
\nextgroupplot[title=$P@5$,xlabel={$\lambda$ values}]
\addplot table [x=lmda,y=1] {inserted/BM25/ap_alpha_p5_cB};
\addplot table [x=lmda,y=2] {inserted/BM25/ap_alpha_p5_cB};
\addplot table [x=lmda,y=3] {inserted/BM25/ap_alpha_p5_cB};
\addplot table [x=lmda,y=4] {inserted/BM25/ap_alpha_p5_cB};
\addplot table [x=lmda,y=5] {inserted/BM25/ap_alpha_p5_cB};
\addplot table [x=lmda,y=6] {inserted/BM25/ap_alpha_p5_cB};
\addplot table [x=lmda,y=7] {inserted/BM25/ap_alpha_p5_cB};
\addplot table [x=lmda,y=8] {inserted/BM25/ap_alpha_p5_cB};
\addplot table [x=lmda,y=9] {inserted/BM25/ap_alpha_p5_cB};
\addplot table [x=lmda,y=10] {inserted/BM25/ap_alpha_p5_cB};
\addplot table [x=lmda,y=11] {inserted/BM25/ap_alpha_p5_cB};
\addplot table [x=lmda,y=12] {inserted/BM25/ap_alpha_p5_cB};
\addplot table [x=lmda,y=13] {inserted/BM25/ap_alpha_p5_cB};
\addplot table [x=lmda,y=14] {inserted/BM25/ap_alpha_p5_cB};
\addplot table [x=lmda,y=15] {inserted/BM25/ap_alpha_p5_cB};
\addplot table [x=lmda,y=16] {inserted/BM25/ap_alpha_p5_cB};
\addplot table [x=lmda,y=17] {inserted/BM25/ap_alpha_p5_cB};
\addplot table [x=lmda,y=18] {inserted/BM25/ap_alpha_p5_cB};
\addplot table [x=lmda,y=19] {inserted/BM25/ap_alpha_p5_cB};
\addplot table [x=lmda,y=20] {inserted/BM25/ap_alpha_p5_cB};
\end{groupplot}
\path (myplot c1r1.outer north west)% plot in column 1 row 1
-- node[anchor=south,rotate=90] {}% label midway
(myplot c1r1.outer south west)% plot in column 1 row 4
;
% legend
\path (myplot c1r1.north west|-current bounding box.north)--
coordinate(legendpos)
(myplot c2r1.north east|-current bounding box.north);
\matrix[
matrix of nodes,
anchor=south,
draw,
inner sep=0.2em,
draw
]at([yshift=0.5ex]legendpos)
{
\ref{plots:plot1}& 1&[5pt]
\ref{plots:plot2}& 2&[5pt]
\ref{plots:plot3}& 3&[5pt]
\ref{plots:plot4}& 4&[5pt]
\ref{plots:plot5}& 5&[5pt]
\ref{plots:plot6}& 6\\
\ref{plots:plot7}& 7&[5pt]
\ref{plots:plot8}& 8&[5pt]
\ref{plots:plot9}& 9&[5pt]
\ref{plots:plot10}& 10&[5pt]
\ref{plots:plot11}& 11&[5pt]
\ref{plots:plot12}& 12\\
\ref{plots:plot13}& 13&[5pt]
\ref{plots:plot14}& 14&[5pt]
\ref{plots:plot15}& 15&[5pt]
\ref{plots:plot16}& 16&[5pt]
\ref{plots:plot17}& 17&[5pt]
\ref{plots:plot18}& 18\\
\ref{plots:plot19}& 19&[5pt]
\ref{plots:plot20}& 20\\};
\end{tikzpicture}
\end{figure}
但正如您所看到的,有些符号用于不同的图,这使得我的图形模棱两可(例如 2 和 12、3 和 13 ...)。我该如何应对?我还想调整曲线的标量(或比例)以分离不同的图,因为它们是堆叠的。
非常感谢。
答案1
正如 Torbjørn 在问题下方的评论中提到的那样,您需要更改来cycle list
解决您的问题,并且有多种可能性可以做到这一点。这里我仅介绍一种使用两个预定义的cycle list
s 来实现此目的的方法。
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
legend entries={1,...,20},
legend pos=outer north east,
legend columns=10,
transpose legend=true,
% ---------------------------------------------------------------------
% adjust that part to get your desired result
% (this is a very simple example to not get repeating styles)
cycle multiindex* list={
color \nextlist
mark list* \nextlist
},
% ---------------------------------------------------------------------
]
\pgfplotsforeachungrouped \i in {1,...,20} {
\addplot coordinates { (0,\i) (1,\i) };
}
\end{axis}
\end{tikzpicture}
\end{document}