![“每个 loglogaxis/.append 样式”在 PGFplots 中不起作用](https://linux22.com/image/311781/%E2%80%9C%E6%AF%8F%E4%B8%AA%20loglogaxis%2F.append%20%E6%A0%B7%E5%BC%8F%E2%80%9D%E5%9C%A8%20PGFplots%20%E4%B8%AD%E4%B8%8D%E8%B5%B7%E4%BD%9C%E7%94%A8.png)
我正在尝试将其应用于科学记数法
对数对数轴中刻度的数字格式不会更改为科学计数法 `ax 10^b`,'a' 为实数,'b' 为整数
通过loglogaxis
使用
\pgfplotsset
{
every loglogaxis/.append style=
{
log number format code/.code=
{
\pgfkeys{/pgf/fpu}
\pgfmathparse{exp(\tick)}
\pgfmathprintnumber[sci,sci zerofill,precision=2]{\pgfmathresult}
\pgfkeys{/pgf/fpu=false}
}
}
}
在我的文档的序言中LaTeX
。然而,它似乎被完全忽略了,见下图。
我该如何解决?
最小工作示例:
\documentclass[margin=1cm]{standalone}
\usepackage{pgfplots}
\usetikzlibrary{calc}
\pgfplotsset
{
compat=newest,
every loglogaxis/.append style=
{
log number format code/.code=
{
\pgfkeys{/pgf/fpu}
\pgfmathparse{exp(\tick)}
\pgfmathprintnumber[sci,sci zerofill,precision=2]{\pgfmathresult}
\pgfkeys{/pgf/fpu=false}
}
} % DOESN'T WORK!
}
\begin{document}
\begin{tikzpicture}
\begin{loglogaxis}
[
name=plot_left,
xtick={1,95},
%log number format code/.code={\pgfkeys{/pgf/fpu}\pgfmathparse{exp(\tick)}\pgfmathprintnumber[sci,sci zerofill,precision=1]{\pgfmathresult}\pgfkeys{/pgf/fpu=false}} % WORKS!
]
\addplot[no marks,domain=10^0:10^3] {x};
\end{loglogaxis}
\begin{loglogaxis}
[
name=plot_right,
at={($(plot_left.east)+(20mm,0)$)},
anchor=west,
xtick={1,95},
%log number format code/.code={\pgfkeys{/pgf/fpu}\pgfmathparse{exp(\tick)}\pgfmathprintnumber[sci,sci zerofill,precision=1]{\pgfmathresult}\pgfkeys{/pgf/fpu=false}} % WORKS!
]
\addplot[no marks,domain=10^0:10^3] {exp(x)};
\end{loglogaxis}
\end{tikzpicture}
\end{document}
结果
答案1
您输入错误。键名是every loglog axis
。
无论代码如何,都不要删除%
代码块中行末的 。否则您将得到虚假的空格。