未知数据格式‘函数’

未知数据格式‘函数’

要么是我有一个令人尴尬的打字错误,要么是 tikz 的最新版本有一个错误。

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{datavisualization}

\begin{document}
\begin{tikzpicture}
  \datavisualization[school book axes, visualize as smooth line]
    data [format=function] {
      var x: interval [-10:10], samples 50;
      func y = sin(\value x)/\value x;
    };
\end{tikzpicture}
\end{document}

我检查了 tikz 源代码,所以存在一个定义,但是没有被加载或者有一个错误的 catcode。

答案1

这算是有点作用了。

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{datavisualization.formats.functions}


\begin{document}
\begin{tikzpicture}
  \datavisualization[school book axes, visualize as smooth line]
    data[format=function] {
      var x : interval [-10:10] samples 50;
      func y = sin(\value x) / \value x;
    };
\end{tikzpicture}
\end{document}

答案2

为了完整性,最终的解决方案是改用 pgfplots。school book axes对 x 和 y 使用相同的比例。

\documentclass{standalone}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
\begin{axis}[axis lines=middle, ymax=1.1, clip=false]
\addplot[domain=-10:10 ,samples=50, smooth] {sin(deg(x))/x};
\end{axis}
\end{tikzpicture}
%
\begin{tikzpicture}
\begin{axis}[axis lines=middle,name=border, ymax=1.01, smooth]
\addplot[domain=-.5:.5 ,samples=20] {sin(deg(x))/x};
\coordinate (A) at (axis cs: -0.2,.99);
\coordinate (B) at (axis cs: 0.2,1.01);
\end{axis}
\draw[blue] (border.west |- A) -- (border.east |- A) node[right] {$b-\epsilon$};
\draw[blue] (border.west |- B) -- (border.east |- B) node[right] {$b+\epsilon$};
\draw[red] (border.south -| A) -- (border.north -| A) node[above left] {$a-\upsilon$};
\draw[red] (border.south -| B) -- (border.north -| B) node[above right] {$a+\upsilon$};
\end{tikzpicture}
\end{document}

演示

相关内容