如何将图表的 x 轴刻度改为科学计数法?目前,$$.10^4$$
如图红框所示,单独显示。
代码:
\documentclass[tikz, border=1cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
% 3N5H_test.csv
\begin{document}
\begin{tikzpicture}
\pgfplotsset{
set layers,% using layers
mark layer=axis tick labels,% defines the layer of the marks
every axis/.append style={scale=0.8}
}
\begin{semilogyaxis}[ xmin=0, xmax=0.1e5,
ymin=1e-4, ymax=1,
xlabel={Number of Flops},
ylabel={Normalized MSE: $\log_{10} (e)$ },
scatter/classes={ a={mark=square*, blue}, b={mark=square*, red}, c={mark=square, black}, d={mark=triangle*, blue}, e={mark=triangle*, red},f={mark=triangle*, black},g={mark=x, black}, h={mark= diamond*, pink} },
]
\addplot[scatter, only marks,
scatter src=explicit symbolic]
table[meta=label] {
x y label
1320.9279232530525 0.06258769833615981 a
};
\addplot[scatter, only marks,
scatter src=explicit symbolic]
table[meta=label] {
x y label
7320.9279232530525 0.002258769833615981 b
};
\end{semilogyaxis}
\end{tikzpicture}
\end{document}
答案1
您可以使用xticklabel style
设置标签的样式X-axis./pgf/number format/sci
将每个标签数字更改为科学计数法,并scaled ticks=false
确保科学计数法指数不会像原始图表中那样浮动到右下角。由于科学计数法占用大量空间,我擅自旋转了您的X-标签,以便于阅读。
\documentclass[border=1cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
\pgfplotsset{
set layers,% using layers
mark layer=axis tick labels,% defines the layer of the marks
every axis/.append style={scale=0.8}
}
\begin{semilogyaxis}[
xmin=0, xmax=0.1e5,
ymin=1e-4, ymax=1,
xlabel={Number of Flops},
ylabel={Normalized MSE: $\log_{10} (e)$ },
scatter/classes={
a={mark=square*, blue},
b={mark=square*, red},
c={mark=square, black},
d={mark=triangle*, blue},
e={mark=triangle*, red},
f={mark=triangle*, black},
g={mark=x, black},
h={mark= diamond*, pink}
},
xticklabel style={
/pgf/number format/sci,
scaled ticks = false,
rotate = 90
}
]
\addplot[scatter, only marks,scatter src=explicit symbolic]
table[meta=label] {
x y label
1320.9279232530525 0.06258769833615981 a
};
\addplot[scatter, only marks,scatter src=explicit symbolic]
table[meta=label] {
x y label
7320.9279232530525 0.002258769833615981 b
};
\end{semilogyaxis}
\end{tikzpicture}
\end{document}