1

I would like to represent a curve in the plane (i.e. a continuous map from a one-dimensional space to a 2-dimensional space). The (parametric) equation of the curve is (x,y)=(f(t),g(t)) where t real and f,g two fuctions of t. These two functions are too complicated to be written here but my question does not depend on their forms, because I would like to draw this curve by using tikz. How do I do that?

EDIT For example, the following code:

\begin{tikzpicture}
   \begin{axis}[samples y=0]
    \addplot3+[domain=0:1] (x,x^2,x^3);
    \end{axis}
\end{tikzpicture}

works well on three dimensional space. But how I could use it for the plane?

  • 1
    Well, if f and g are too complicated to be written, how would you tell TikZ what to plot? You can easily plot curves in a plane e.g. using tikz-3dplot and the 3d library but you need to know what you want to plot. – marmot Mar 25 at 18:07
  • Your plot in the example has three coordinates (x, x^2, x^3) so you will have to do a change of axis to plot it in 2 dimensions? – RockyRock Mar 25 at 18:30
2

You can parametrize with t your function in (x,y,z) as follows:

\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\begin{document}
\begin{tikzpicture}
\begin{axis}[width=0.75*\textwidth,
                axis lines=left,
                xlabel=$x$,
                ylabel=$y$,
                zlabel=$z$,
                zmin=0,
                zmax=1,
                ticks=none,
                view={240}{20},
                unbounded coords=jump,
                z filter/.expression={z>1 ? nan : z},
                restrict z to domain*=0:1]
\addplot3[variable=t, mesh, draw=black!50, domain=-1:1] ({t^2},{t},1);
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

Or in two dimensions

  \documentclass{article}
    \usepackage{tikz}
    \usepackage{pgfplots}
    \pgfplotsset{compat=newest}

    \begin{document}
\begin{center}
\begin{tikzpicture}
\begin{axis}
\addplot[blue, samples=40, variable=\t, domain=0:4]
    ({125*t*cos(deg(30)))},
    {3+125*t*sin(deg(30))-16*t^2});
\end{axis}
\end{tikzpicture}
\end{center}
    \end{document}

enter image description here

Hope that helps!

Romain

  • 1
    Thank you RockyRock! I updated my post. – Mark Mar 25 at 18:18

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.