我正在尝试绘制一些数值模拟数据,并希望显示这些数据(见下面的代码)。但 10 的幂确实有奇怪的额外小数位(见图)。有没有办法去掉这些奇怪的小数位?
\begin{figure}[H]
\begin{tikzpicture}
\begin{axis}[
height = 10cm, % standard 10cm
width = 15cm, % standard 10cm
xlabel = {$N$},
ylabel = {$e_h$},
grid=both,
major grid style={black!50},
xmode=log, ymode=log,
xmin=1e0, xmax=1e4,
ymin=1e-3, ymax=1e1,
yticklabel style={
/pgf/number format/fixed,
/pgf/number format/precision=0,
/pgf/number format/fixed zerofill
},
scaled y ticks=false,
xticklabel style={
/pgf/number format/fixed,
/pgf/number format/precision=0,
/pgf/number format/fixed zerofill
},
scaled y ticks=false,
cycle list name=my black white
]
\addplot table [x=N, y = eh, col sep=comma] {Plots/results2.txt};
\legend{$e_h$}
\end{axis}
\end{tikzpicture}
\end{figure}
编辑:常规 pdfkeys 设置:
%=========== Gloabal Tikz settings
\pgfplotsset{compat=newest}
\usetikzlibrary{math}
\pgfplotsset{
height = 10cm,
width = 10cm,
tick pos = left,
legend style={at={(0.98,0.66)}, anchor=east},
legend cell align=left,
}
\pgfkeys{
/pgf/number format/.cd,
fixed,
%fixed zerofill,
precision = 1,
set thousands separator = {}
}
答案1
我删除了/pgf/number format/fixed zerofill
代码
\documentclass[margin=1cm]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
height = 10cm, % standard 10cm
width = 15cm, % standard 10cm
xlabel = {$N$},
ylabel = {$e_h$},
grid=both,
major grid style={black!50},
xmode=log, ymode=log,
xmin=1e0, xmax=1e4,
ymin=1e-3, ymax=1e1,
yticklabel style={
/pgf/number format/fixed,
/pgf/number format/precision=0
},
scaled y ticks=false,
xticklabel style={
/pgf/number format/fixed,
/pgf/number format/precision=0
},
scaled y ticks=false,
%cycle list name=my black white
]
% \addplot table [x=N, y = eh, col sep=comma] {Plots/results2.txt};
% \legend{$e_h$}
\end{axis}
\end{tikzpicture}
\end{document}