有没有办法将下列奇妙的工具结合起来?
- tikz/数学函数“执行解析器之外的代码”
- pgf图
我尝试过以下方法:
\documentclass[tikz]{standalone}
\usetikzlibrary{math,calc}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}[myStyle/.style = {fill = white, text = blue,}, every node/.style = myStyle ]
\begin{axis}[domain=0:4,]
\addplot[]{x};
\tikzmath
{
\a = 2 ;
{
\node at (axis cs: \a,\a) {this is ok} ;
};
function test(\variable)
{
{
\node at (axis cs: \variable,\variable) {but this fails !} ;
\node at (axis cs: \a,\a) {also this fails : \variable} ;
};
};
%test(3); % --- how do I protect my tikz/math function from pgfplots ?
}
\end{axis}
\end{tikzpicture}
\end{document}
(取消注释该%test(3)
行会导致代码失败。)
并且函数调用test
失败,因为\variable
Pgfplots 无法识别......
\node
因此推测语句的扩展方式出了问题?
干杯,