我的散点图的图例没有捕捉到我使用的标记的大小。我在这里说得比较极端,以便明显看出区别。我希望了解如何让尺寸准确地反映在图例中。
\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{semilogyaxis}
\addplot[ only marks,scatter,scatter src=explicit symbolic,
scatter/classes={
1={mark=square*,red},
2={mark=triangle*,scale=3,blue},
3={mark=*,,scale=0.5,orange}
}]
table[col sep=comma,x=Time,y=Error,meta=MethodID] {
RunID, MethodID, Method, Error, Time
1, 1, A, 0.0867695, 11.480295
1, 2, B, 0.0866708, 9.202405
1, 3, C, 0.086605, 7.313438
2, 1, A, 0.00846272, 15.640081
2, 2, B, 0.00846088, 10.154310
2, 3, C, 0.00846057, 17.586641
3, 1, A, 0.000857559, 20.381943
3, 2, B, 0.000857549, 15.004824
3, 3, C, 0.000857547, 33.210958
4, 1, A, 8.42488e-05, 24.970190
4, 2, B, 8.42485e-05, 17.180806
4, 3, C, 8.42482e-05, 33.687078
};
\legend{A,B,C}
\end{semilogyaxis}
\end{tikzpicture}
\end{document}
答案1
mark size
您应该使用仅缩放标记的选项,而不是scale
。这样,图例中的标记也会缩放。
该选项mark size
采用默认的尺寸2pt
。因此,为了将标记缩放到原始大小的三倍,您需要设置mark size=6pt
。
\documentclass[border=10pt]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{semilogyaxis}
\addplot[only marks,scatter,scatter src=explicit symbolic,
scatter/classes={
1={mark=square*,red},
2={mark=triangle*,mark size=6pt,blue},
3={mark=*,mark size=1pt,orange}
}]
table[col sep=comma,x=Time,y=Error,meta=MethodID] {
RunID, MethodID, Method, Error, Time
1, 1, A, 0.0867695, 11.480295
1, 2, B, 0.0866708, 9.202405
1, 3, C, 0.086605, 7.313438
2, 1, A, 0.00846272, 15.640081
2, 2, B, 0.00846088, 10.154310
2, 3, C, 0.00846057, 17.586641
3, 1, A, 0.000857559, 20.381943
3, 2, B, 0.000857549, 15.004824
3, 3, C, 0.000857547, 33.210958
4, 1, A, 8.42488e-05, 24.970190
4, 2, B, 8.42485e-05, 17.180806
4, 3, C, 8.42482e-05, 33.687078
};
\legend{A,B,C}
\end{semilogyaxis}
\end{tikzpicture}
\end{document}