Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am trying to plot a spiral such that it is orientated as shown in the rough sketch. The spiral is coming out of the screen.

enter image description here

The script below yields the diagram shown at the end, but whatever I do I cannot seem to get the orientations as shown above. Looking at the pgfplot manual am I correct in thinking that I can only rotate about the z axis and vertically up and down? Any suggestions?

\begin{tikzpicture}
\begin{axis}[view={60}{30},
axis lines=center,axis on top,
zmin=0, zmax=8,
xmin=-2,xmax=2,
ymin=-2,ymax=2,
width=6cm,height=6cm]
\addplot3+[no markers,line width=2pt,color=orange,domain=0:10*pi,samples=80,samples y=0]
  ({sin(deg(x))},
   {cos(deg(x))},
   {2*x/(5*pi)});
\end{axis}
\end{tikzpicture}

enter image description here

share|improve this question
add comment

1 Answer

up vote 10 down vote accepted

You need to change the parametrization so that you're using:

{2*x/(5*pi)},
{sin(deg(x))},
{cos(deg(x))}

which brings the spiral along the x axis.

screenshot

% arara: pdflatex
% !arara: indent: {overwrite: yes}
\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\begin{document}
\begin{tikzpicture}
    \begin{axis}[view={60}{30},
            axis lines=center,axis on top,
            zmin=-2, zmax=2,
            xmin=-2,xmax=8,
            ymin=-2,ymax=2,
        width=6cm,height=6cm]
        \addplot3+[no markers,line width=2pt,color=orange,domain=0:10*pi,samples=80,samples y=0]
        (
        {2*x/(5*pi)},
        {sin(deg(x))},
        {cos(deg(x))}
        );
    \end{axis}
\end{tikzpicture}
\end{document} 

Just for demonstration, here's the 'other' orientation (along the y axis)

screenshot

% arara: pdflatex
% !arara: indent: {overwrite: yes}
\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\begin{document}
\begin{tikzpicture}
    \begin{axis}[view={60}{30},
            axis lines=center,axis on top,
            zmin=-2, zmax=2,
            xmin=-2,xmax=2,
            ymin=-2,ymax=8,
        width=6cm,height=6cm]
        \addplot3+[no markers,line width=2pt,color=orange,domain=0:10*pi,samples=80,samples y=0]
        (
        {sin(deg(x))},
        {2*x/(5*pi)},
        {cos(deg(x))}
        );
    \end{axis}
\end{tikzpicture}
\end{document}
share|improve this answer
    
Never occurred to me to do that. It obviously works and I am using it. –  rhody Feb 23 at 1:37
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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