# foreach within \draw, without giving the first point explicitly

I am plotting line given by y(x) expression evaluated at regularly spaced points, e.g.

\def\ffIiC{+0.0436275-1.18778*\x^1+0.542693*\x^2}
% ...
\draw (0,0.0436275) \foreach\x in {0,.1,...,4}{ -- ({\x},{\ffIiiC}) };
%     ^^^^^^^^^^^^^


However, I always need to specify the first point explicitly. Is there a way to avoid that?

-
Having always a small MWE allows other people to simply copy and paste it and test their solutions. TikZ is complex enough that solutions should be tested previous before posting. –  Martin Scharrer Dec 14 '11 at 10:52

A -- without a previous coordinate seems to be the issue. You can add a conditional to have the -- suppressed for the first value.

\documentclass{article}
\usepackage{tikz}

\begin{document}
\tikz {
\def\ffIiC{+0.0436275-1.18778*\x^1+0.542693*\x^2}
\draw \foreach\x in {0,.1,...,4} {
\ifdim\x pt=0pt \else--\fi
({\x},{\ffIiC})
};
}
\end{document}


Note: The space before \else is important, otherwise an error is caused. TeX seems to add an implicit \relax as terminator for the dimension expression in that case which breaks the TikZ path.

-
Thanks, I wrote it shorter with count as \draw \foreach\x [count=\xi] in {0,.1,...,4}{ \ifnum\xi=1 \else--\fi ({\x},{\ffIiC}) }; but it still feels more awkward than I would like it to be... –  eudoxos Dec 14 '11 at 11:15
Yes, it doesn't look that nice. It would be nice if you could give special code for the first and maybe last iteration. –  Martin Scharrer Dec 14 '11 at 11:19
It's preferable to avoid the conditional inside the \foreach (time consuming). I prefer to keep the first point outside and in this case, the loop begins with 0.1 and not 0. –  Alain Matthes Dec 14 '11 at 11:19
@Altermundus: Yes, but this means code repetition. In this case it is still manageable, but in general a nicer solution would be great. –  Martin Scharrer Dec 14 '11 at 11:22
Isn't there way to give some not-a-point (like NaN) coordinate to TikZ, so that the first point would be simply ignored? –  eudoxos Dec 14 '11 at 11:34