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
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}