![有人能帮我弄清楚这个 TiKZ 代码的作用吗?](https://linux22.com/image/387568/%E6%9C%89%E4%BA%BA%E8%83%BD%E5%B8%AE%E6%88%91%E5%BC%84%E6%B8%85%E6%A5%9A%E8%BF%99%E4%B8%AA%20TiKZ%20%E4%BB%A3%E7%A0%81%E7%9A%84%E4%BD%9C%E7%94%A8%E5%90%97%EF%BC%9F.png)
\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}
\begin{document}
\newcommand{\xmax}{14}
\newcommand{\fmin}{(pi/3)}
\newcommand{\fmax}{(2*pi)}
\begin{tikzpicture}[domain=0:\xmax, samples=500]
\draw[ultra thick, red] plot (\x, {sin(deg(exp(ln(\fmin)+\x/\xmax*(ln(\fmax)-ln(\fmin)))*\x))} );
\end{tikzpicture}
\end{document}
如果 LaTeX 多次重复此语句下方的代码,我就会理解。
答案1
我只会在代码中添加注释,希望能解释一切
\documentclass{standalone}
\usepackage{tikz}
\begin{document}
% define some constants
\newcommand{\xmax}{14}
\newcommand{\fmin}{(pi/3)}
\newcommand{\fmax}{(2*pi)}
% begin a tikzpicture that will pass the options domain and samples with the given value to each command inside of it.
\begin{tikzpicture}[domain=0:\xmax, samples=500]
% Use the plot command from tikz on the given function.
% the function will be evaluated between 0 < x < 500 as these were the borders specified in the domain-option
% in total 500 equidistant points of this function will be calculated as this was the value for the samples option
% Every calculated point will be connected to its neighbours which will raise the impression
% that the function was indeed plotted continuously and not for discrete values only.
% You will see what I mean when you set samples to a low value like 5 or something like that.
% In total the function will be evaluated 500 times. Every time \x is set to the respective value and it is up to the code to actually draw a point.
% This is done by the normal coordinate specification in which \x is used as the x-coordinate and the result of the function as the y-coordinate.
% This results in a normal (<number>,{<mathematical expression>}) syntax for coordinates
\draw[ultra thick, red] plot (\x, {sin(deg(exp(ln(\fmin)+\x/\xmax*(ln(\fmax)-ln(\fmin)))*\x))} );
\end{tikzpicture}
\end{document}