سلام
2 سوال دارم. ممنون می شوم کمک کنید.
1- در کد کمینه زیر دوبار legend ظاهر می شود (مثلا کنار M1 را نگاه کنید)
2- چطور می توانم برای کل زیرشکلها فقط یک legend بگذارم.
کد کمینه:
\documentclass{article}
\usepackage{pgfplots}
\usetikzlibrary{patterns}
\usepackage{subfig} % Para hacer los subfigure
\usepackage{float}%Posicionamiento fijo con "[H]"
\begin{document}
\begin{figure}[htbp]
\centering
\subfloat[SF50]{
\begin{tikzpicture}
\begin{axis}[ybar, legend style={fill=none},
width=0.49\linewidth,
bar width=0.04cm,
xlabel={$k$},
ylabel={$\Delta ACC$},
xtick=data,
%ytick=data,
enlarge y limits=true,
legend pos=north west, legend entries={M1,M2,M3,M4}
%enlarge y limits={upper,value=0.1},
%,every node near coord/.append style={rotate=90, anchor=west, font=\footnotesize}
]
\addplot [draw=red,pattern=horizontal lines] coordinates { (2,0.0000) (3,0.0402) (4,0.0660) (5,0.1246) (6,0.1434) (7,0.1478) (8,0.1777) (9,0.1801) (10,0.2024)};
\addplot [draw=green,pattern=crosshatch] coordinates { (2,0.0000) (3,0.1506) (4,0.2411) (5,0.2631) (6,0.2775) (7,0.3100) (8,0.3283) (9,0.3391) (10,0.3508)};
\addplot [draw=blue,pattern=north east lines] coordinates { (2,0.0000) (3,0.1156) (4,0.1850) (5,0.2246) (6,0.2743) (7,0.3158) (8,0.3452) (9,0.3406) (10,0.3471)};
\addplot [draw=black,pattern=north west lines] coordinates { (2,0.0000) (3,0.1837) (4,0.2388) (5,0.2668) (6,0.3146) (7,0.3363) (8,0.3490) (9,0.3570) (10,0.3560)};
\end{axis}
\end{tikzpicture}
}
\subfloat[RA82]{
\begin{tikzpicture}
\begin{axis}[ybar, legend style={fill=none},
width=0.49\linewidth,
bar width=0.04cm,
xlabel={$k$},
ylabel={$\Delta ACC$},
xtick=data,
%ytick=data,
enlarge y limits=true,
legend pos=north west, legend entries={M1,M2,M3,M4}
%enlarge y limits={upper,value=0.1},
%,every node near coord/.append style={rotate=90, anchor=west, font=\footnotesize}
]
\addplot [draw=red,pattern=horizontal lines] coordinates { (2,0.0000) (3,0.0000) (4,0.0232) (5,0.0659) (6,0.0756) (7,0.1028) (8,0.1359) (9,0.1555) (10,0.2065)};
\addplot [draw=green,pattern=crosshatch] coordinates { (2,0.2343) (3,0.4221) (4,0.4144) (5,0.4501) (6,0.5162) (7,0.5067) (8,0.5273) (9,0.5518) (10,0.5846)};
\addplot [draw=blue,pattern=north east lines] coordinates { (2,0.0724) (3,0.1817) (4,0.2880) (5,0.3872) (6,0.4093) (7,0.4371) (8,0.4721) (9,0.4876) (10,0.5048)};
\addplot [draw=black,pattern=north west lines] coordinates { (2,0.4814) (3,0.4556) (4,0.4166) (5,0.3998) (6,0.3542) (7,0.3305) (8,0.3107) (9,0.2869) (10,0.2675)};
\end{axis}
\end{tikzpicture}
}\\
\subfloat[Polbooks]{
\begin{tikzpicture}
\begin{axis}[ybar, legend style={fill=none},
width=0.49\linewidth,
bar width=0.04cm,
xlabel={$k$},
ylabel={$\Delta ACC$},
xtick=data,
%ytick=data,
enlarge y limits=true,
legend pos=north west, legend entries={M1,M2,M3,M4}
%enlarge y limits={upper,value=0.1},
%,every node near coord/.append style={rotate=90, anchor=west, font=\footnotesize}
]
\addplot [draw=red,pattern=horizontal lines] coordinates { (2,0.0000) (3,0.0080) (4,0.0254) (5,0.0545) (6,0.1003) (7,0.1372) (8,0.1690) (9,0.1997) (10,0.2128)};
\addplot [draw=green,pattern=crosshatch] coordinates { (2,0.0000) (3,0.0040) (4,0.0182) (5,0.0403) (6,0.0699) (7,0.0973) (8,0.1228) (9,0.1397) (10,0.1602)};
\addplot [draw=blue,pattern=north east lines] coordinates { (2,0.0000) (3,0.0083) (4,0.0273) (5,0.0520) (6,0.0838) (7,0.1064) (8,0.1254) (9,0.1403) (10,0.1465)};
\addplot [draw=black,pattern=north west lines] coordinates { (2,0.0000) (3,0.0076) (4,0.0180) (5,0.0457) (6,0.0734) (7,0.0890) (8,0.1062) (9,0.1168) (10,0.1261)};
\end{axis}
\end{tikzpicture}
}
\subfloat[Football]{
\begin{tikzpicture}
\begin{axis}[ybar, legend style={fill=none},
width=0.49\linewidth,
bar width=0.04cm,
xlabel={$k$},
ylabel={$\Delta ACC$},
xtick=data,
%ytick=data,
enlarge y limits=true,
legend pos=north west, legend entries={M1,M2,M3,M4}
%enlarge y limits={upper,value=0.1},
%,every node near coord/.append style={rotate=90, anchor=west, font=\footnotesize}
]
\addplot [draw=red,pattern=horizontal lines] coordinates { (2,0.0000) (3,0.0000) (4,0.0000) (5,0.0000) (6,0.0000) (7,0.0000) (8,0.0007) (9,0.0021) (10,0.0037)};
\addplot [draw=green,pattern=crosshatch] coordinates { (2,0.0000) (3,0.0000) (4,0.0000) (5,0.0000) (6,0.0000) (7,0.0000) (8,0.0007) (9,0.0021) (10,0.0045)};
\addplot [draw=blue,pattern=north east lines] coordinates { (2,0.0000) (3,0.0000) (4,0.0000) (5,0.0000) (6,0.0000) (7,0.0000) (8,0.0010) (9,0.0035) (10,0.0087)};
\addplot [draw=black,pattern=north west lines] coordinates { (2,0.0000) (3,0.0000) (4,0.0000) (5,0.0000) (6,0.0000) (7,0.0000) (8,0.0017) (9,0.0046) (10,0.0089)};
\end{axis}
\end{tikzpicture}
}
\caption{The value of $\Delta ACC$ for different datasets and models in $k=2\ldots 10$. }
\label{fig:DACC}
\end{figure}
\end{document}