Quantcast
Viewing latest article 2
Browse Latest Browse All 4

Answer by Heiko Oberdiek for `Missing = inserted for \ifnum` when using addplot

pgfplots uses library fpu for better precision by default, which has a different internal number format. Therefore \pgfresult is not 1 or 0 anymore and \ifnum cannot be used.

\tikzset{fpu}\pgfmathparse{int(0)}\show\pgfmathresult\pgfmathparse{int(1)}\show\pgfmathresult

The lines show 0Y0 for zero and 1Y1 for one.

In this case, the whole math can be put in one \pgfmathparse expression:

\documentclass{scrreprt}\usepackage{pgfplots}\pgfplotsset{compat=1.12}\begin{document}\begin{tikzpicture}    % http://tex.stackexchange.com/a/235009    \pgfmathdeclarefunction{sincf}{1}{%        \pgfmathparse{(abs(#1)<0.01) ? 1 : sin(pi*#1 r)/(pi*#1)}%    }    \begin{axis}        \addplot {sincf(\x)};    \end{axis}\end{tikzpicture}\end{document}

Image may be NSFW.
Clik here to view.
Result


Viewing latest article 2
Browse Latest Browse All 4

Trending Articles