是否可以在 tikz 图片中使用格式/固定和逗号作为分隔符?
我使用了下面的代码并收到以下错误消息:包 pgfkeys 错误:我不知道键“/pgf/number format/smooth”,我将忽略它。
\documentclass[a4paper, 12pt]{book}
\usepackage{fontspec}
\setmainfont{Cambria}
\setsansfont{Calibri}
\newfontfamily\Headerfamily{Calibri}
\usepackage[ngerman]{babel}
\usepackage{graphicx}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usepackage{mathtools}
\usepackage{siunitx}
\newcommand\arr{\tikz[baseline=-0.6ex]\draw[-latex] (0,0) -- + (7mm,0);}
\begin{document}
\begin{tikzpicture}
\begin{axis}[domain=0:45,
/pgf/number format=use comma,
/pgf/number format/fixed,
samples=180,
grid=major,smooth,
xmin=0,
xmax=45,
ymin=-0.1,
ymax=0.1,
xlabel={\si{\celsius} \arr},
ylabel={\si{\radian} \arr},
legend pos=north west]
\legend{\emph{Drift}}
\addplot [color=black,thick]
{(0.000001*x^3+
(-0.000035*x^2+
(-0.000315*x};
\end{axis}
\end{tikzpicture}
\end{document}
答案1
只需添加一行。请参阅代码中的注释。
% used PGFPlots v1.16
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{
compat=1.3,
}
\usepackage{siunitx}
\newcommand\arr{\tikz[baseline=-0.6ex]\draw[-latex] (0,0) -- + (7mm,0);}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
/pgf/number format/.cd,
fixed,
use comma,
/tikz/.cd, % <--added
domain=0:45,
samples=180,
grid=major,
smooth,
xmin=0,
xmax=45,
ymin=-0.1,
ymax=0.1,
xlabel={\si{\celsius} \arr},
ylabel={\si{\radian} \arr},
legend pos=north west,
]
\addplot [color=black,thick]
{0.000001*x^3+
-0.000035*x^2+
-0.000315*x};
\legend{\emph{Drift}}
\end{axis}
\end{tikzpicture}
\end{document}