[Tex/LaTex] How to draw a parametric 3D curve in tikz

plottikz-pgf

I would like to use tikz or a similar LaTeX package to draw the following curve in a three-dimensional coordinate system

(t^2, t*(1-t), 1-t) for t in (0,1).

Is there an easy way to do this? Thanks!

Best Answer

pgfplots is an option:

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.12}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot3[variable=t,mesh,domain=0:1] (t^2,{ t*(1-t)}, 1-t);
\end{axis}
\end{tikzpicture}
\end{document}

which looks like

enter image description here


With view={<azimuth>}{<elevation>} you can rotate the view to an angle where the features of the curve are easier visible. If you want to help further with depth perception, you can for instance add e.g. support lines:

\documentclass[tikz, border=2mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.12}

\begin{document}

\begin{tikzpicture}
\begin{axis}
[   view={60}{30},
    enlargelimits=false,
]
    \pgfplotsinvokeforeach{0,0.1,...,1}
    { \draw[gray] (#1*#1,#1-#1*#1,1-#1) -- (#1*#1,#1-#1*#1,0);
    }

    \addplot3[variable=t,mesh,domain=0:1] (t^2,t-t^2,1-t);

    \end{axis}
\end{tikzpicture}

\end{document}

enter image description here