首先,这是高层的抱怨。pgfplots 是一个很棒的软件包,我想感谢 Christian Feuersänger 和其他开发人员的工作。请考虑下面的最小示例。
\documentclass{standalone}
\usepackage{filecontents}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\pgfplotsset{compat=newest}
\pgfkeys{/pgf/number format/set thousands separator = }
\begin{filecontents}{\jobname.dat}
N l01 l06
1.6000000e+01 2.3772638e-03 9.3626135e-01
3.2000000e+01 5.9319990e-04 2.3388025e-01
6.4000000e+01 1.4823007e-04 5.8468012e-02
1.2800000e+02 3.7053144e-05 1.4616985e-02
2.5600000e+02 9.2630106e-06 3.6542466e-03
5.1200000e+02 2.3157442e-06 9.1356170e-04
1.0240000e+03 5.7880509e-07 2.2839043e-04
2.0480000e+03 1.4436571e-07 5.7097582e-05
4.0960000e+03 3.5634754e-08 1.4274236e-05
\end{filecontents}
\begin{document}
\begin{tikzpicture}
\begin{loglogaxis}[
xlabel={Anzahl der Punkte $N$},
title={Fehler},
legend entries={$\lambda_1$,$\lambda_2$},
legend columns=2,
legend pos=north east,
xmin=1.0e1,
xmax=1.0e4,
ymax=2,
ymin=1.0e-8,
grid=major,
enlarge y limits=.4,]
\addplot+[only marks] table[x=N,y=l01] {\jobname.dat};
\addplot+[only marks] table[x=N,y=l06] {\jobname.dat};
\addplot[forget plot,red] table [
x=N,
y={create col/linear regression={y=l06,
variance list={500,400,200,100}}}] {\jobname.dat}
coordinate [pos=0.1] (AA)
coordinate [pos=0.4] (BB);
\xdef\slopeB{\pgfplotstableregressiona} % save the slope parameter
\draw (AA) -| (BB) % draw the opposite and adjacent sides of the triangle
node [pos=0.25,anchor=south] {1} % label the horizontal line
node [pos=0.75,anchor=west] {\pgfmathprintnumber[precision=2] {\slopeB}};
\end{loglogaxis}
\end{tikzpicture}
\end{document}
输出如下:
如何强制 pgfplots 绘制像 x 轴那样的次要 y 轴刻度?