2

What I want to do is draw a line between points that are defined in a command like this but without the connect to (0,0):

\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\def\new{0.85,0.81,0.77,0.73,0.77}
\draw (0,0)
  \foreach \y [count = \xi ] in \new {-- (\xi,\y*10)};
\end{tikzpicture}
\end{document}

The points in \new are auto generated by another program, so I cannot hard code the first coordinate into the first point. Is there a way to solve this without splitting the list beforehand?

  • 1
    please provide complete small document with your deffinitins in its preamble needed for compilation of your code snippet. – Zarko Feb 19 '18 at 20:08
  • but i ask you for complete document ... is so difficult to extend your code snippet to it? – Zarko Feb 19 '18 at 20:12
  • @Zarko it should be a working example now – user19760 Feb 19 '18 at 20:14
  • yes, now it is :-) – Zarko Feb 19 '18 at 20:17
4

You may want to include an \if clause (see here):

\documentclass[tikz,border=5mm]{standalone}

\begin{document}

\begin{tikzpicture}[dot/.append style=fill]

\def\new{0.85,0.81,0.77,0.73,0.77}
\draw 
\foreach \y [count = \xi] in \new {
 \ifnum\xi>1--\fi (\xi,\y*10) node[dot](point\xi){}
};

\end{tikzpicture}

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.