我正在尝试为我的项目报告创建一个 pgfplot。但无法用科学计数法将我的图的轴转换为对数刻度。有人能指出我的错误并提供帮助吗?
输出:
代码:
\documentclass{article}
\usepackage{tikz,pgfplots}
\usepgfplotslibrary{units}
\begin{document}
\begin{tikzpicture}
\begin{axis}[%
xmin=-2,xmax=10,
ymin=1e-5,ymax=1,
xlabel={Number of Epochs},
ylabel={Normalized MSE: $\log_{10} (e)$ },
ylabel style={align=center, font=\bfseries\boldmath},
xlabel style={align=center, font=\bfseries\boldmath},
x tick label style={font=\bfseries\boldmath},
y tick label style={font=\bfseries\boldmath},
log ticks with fixed point,
scatter/classes={%
a={mark=square*,blue},%
b={mark=triangle*,red},%
c={mark=o,draw=black}}]
\addplot[scatter,only marks,%
scatter src=explicit symbolic]%
table[meta=label] {
x y label
0.1 0.15 a
0.45 0.27 c
0.02 0.17 a
0.06 0.1 a
0.9 0.5 b
0.5 0.3 c
0.85 0.52 b
0.12 0.05 a
0.73 0.45 b
0.53 0.25 c
0.76 0.5 b
0.55 0.32 c
};
\end{axis}
\end{tikzpicture}
\end{document}
答案1
\documentclass[tikz, border=1cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
\begin{semilogyaxis}[
xmin=-2, xmax=10,
ymin=1e-2, ymax=1e0,
xlabel={Number of Epochs},
ylabel={Normalized MSE: $\log_{10} (e)$ },
label style={font=\bfseries\boldmath},
tick label style={font=\bfseries\boldmath},
scatter/classes={a={mark=square*, blue}, b={mark=triangle*, red}, c={mark=o, black}},
]
\addplot[scatter, only marks,
scatter src=explicit symbolic]
table[meta=label] {
x y label
0.1 0.15 a
0.45 0.27 c
0.02 0.17 a
0.06 0.1 a
0.9 0.5 b
0.5 0.3 c
0.85 0.52 b
0.12 0.05 a
0.73 0.45 b
0.53 0.25 c
0.76 0.5 b
0.55 0.32 c
};
\end{semilogyaxis}
\end{tikzpicture}
\end{document}