1

I am trying to plot the 3D curve $x=e^(t)*cos(t),y=e^(t)*sin(t),z=e^(t)$, $t\in[0,1]$, by using the code

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

\begin{document}

\begin{figure}[h]
 \begin{tikzpicture}
        \begin{axis}
        [view={60}{30},axis lines=center,axis on top,
        xlabel=$x$,ylabel=$y$,zlabel=$z$, xtick={2},ytick={2},ztick={2},no marks,axis equal,xmin=-1,xmax=4,ymin=-1,ymax=4,zmin=-1,zmax=4,enlargelimits={upper=0.1}]
             \addplot3+[no markers,samples=200, domain=0:1,variable=t]({exp(t)*cos(t)},{exp(t)*sin(t)},{exp(t)});
        \end{axis}

 \end{tikzpicture}
\end{figure}

\end{document} 

and nothing is plotted. How can I fix this ?

4

First, I think you meant to use standalone as a class. And then the variable name should be a macro. Also the trig functions accept argument in degrees. So you need to mention that they are in radians with an additional r. To remove the final connection to the inital point you can add samples y=0, For example for the domain -pi:pi you get

\addplot3+[no markers,samples=51, samples y=0,domain=-pi:pi,variable=\t]
                                      ({exp(\t)*cos(\t r)},{exp(\t)*sin(\t r)},{exp(\t)});

Full code

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}
\begin{document}
\begin{tikzpicture}
   \begin{axis}[view={60}{30},
                axis lines=center,axis on top,
                xlabel=$x$,ylabel=$y$,zlabel=$z$,
                xtick={2},ytick={2},ztick={2},
                no marks,axis equal,
                xmin=-1,xmax=4,ymin=-1,ymax=4,zmin=-1,zmax=4,
                enlargelimits={upper=0.1}]
     \addplot3+[no markers,samples=51, samples y=0,domain=-pi:pi,variable=\t]
                                      ({exp(\t)*cos(\t r)},{exp(\t)*sin(\t r)},{exp(\t)});
  \end{axis}
\end{tikzpicture}
\end{document} 

enter image description here

  • Excellent answer, thank you very much @percusse ! – Cris Dec 10 '17 at 14:31
  • Can you post the full code, please ? I still have troubles, it seems that the labels $x$, $y$, $z$ dissapear from the coordinate axes. – Cris Dec 10 '17 at 14:55
  • @Cris See the edit – percusse Dec 10 '17 at 15:22

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.