# How can I draw a spiral with tangential unit vector and labels?

Please, How can I draw these diagrams using TiKZ ?

r = r_{0} e^{bt}, \theta= bt

x= R cos wt, y=R sin wt, z=hwt

• Do you have their functions or formulas? Oct 25 '14 at 19:51
• The first one seems to be a logarithmic spiral, which was done with pstricks. Oct 25 '14 at 20:01
• Welcome to TeX.SX. Questions about how to draw specific graphics that just post an image of the desired result are really not reasonable questions to ask on the site. Please post a minimal compilable document showing that you've tried to produce the image and then people will be happy to help you with any specific problems you may have. See minimal working example (MWE) for what needs to go into such a document. Oct 25 '14 at 20:07
• I think you should show more effort. Oct 26 '14 at 18:54
• Maybe you can try with Mathematica :)
– alfC
Oct 27 '14 at 5:09

direct from the manual.

\documentclass{article}

\usepackage{tikz}
\begin{document}
\begin{tikzpicture}

\draw[domain=0:720,smooth,variable=\t]
plot ({1.5*sin(\t)},0.8*\t/360,{1.5*cos(\t)});
\draw[->] (0,0,0) --( 2,0,0) node[above]{y};
\draw[->] (0,0,0) --( 0,2,0) node[right]{z};
\draw[->] (0,0,0) --( 0,0,2,) node[above]{x};
\end{tikzpicture}
\hspace{3em}
\begin{tikzpicture}

\draw[domain=0:20,smooth,variable=\t,samples=200]
plot ({\t r:3*exp(-0.1*\t)});
\draw[->] (0,0,0) --( 4,0) node[above]{x};
\draw[->] (0,0,0) --( 0,4) node[right]{y};

\end{tikzpicture}

\end{document}


Here is a solution with pstricks for the first figure (the logarithmic spiral):

\documentclass[a4paper, pdf, svgnames]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[f]{esvect}
\pagestyle{empty}
\def\localbasis{\psline{<->}(1,0)(0,0)(0,1)}

\begin{document}

\small
\psset{plotpoints=500, algebraic, arrowinset=0.2, labelsep=3pt}
\begin{pspicture}
\psaxes[labels=none, ticks=none]{->}(0,0)(-4.5,-3)(6,5)
\pnodes(0,0){O}( 4.524; 0.5){M}
\uput{6pt}[u](M){\,\,M}
\rput(O){\localbasis}\uput{3pt}[dr](O){$O$}\uput[d](1,0){{$\vv*{e}{\!\!x }$}}\uput{2pt}[dl](0,0.9){{$\vv*{e}{\!\!y}$}}
\psplot[polarplot, arrows=*-, linecolor=VioletRed, linewidth=1.2pt, dotsize=2.5pt]{0}{25}{5*EXP(-x/5)}
\uput[d](5,0){$\mathrm M(t = 0)$}
\rput{0.5}(M){\localbasis}
\pcline{-o}(O)(M)\naput {$r$}
\psarc[linewidth 0.5pt]{->}{2.2}{0}{0.5}\uput[r](2.2; 0.3){ $θ$}
\pnode(5.7; 0.5){I}\rput[I](I){$\vv*{e}{\!\!r}$}
\psRelNodeVar(M )( I)( 1;1.57){J}\rput[B](J){$\vv*{e}{\!\!θ}$}
\end{pspicture}

\end{document}


Then a code for the helix, with the pst-3dplot package:

\documentclass[a4paper, pdf, x11names]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{MinionPro}
\usepackage[f]{esvect}
\pagestyle{empty}
\def\localbasis{\psline{<->}(1,0)(0,0)(0,1)}
\def\\M{6*\pstPI1}
\begin{document}

\small
\psset{xPlotpoints = 500, plotstyle=curve, linecolor = DarkSeaGreen3, algebraic, arrowinset=0.2, labelsep=3pt}
\begin{pspicture}(-4,-2.5)(4,5.5)
\pstThreeDCoor[zMax=5.5, yMax=5, xMax=5, linewidth=0.6pt, linecolor=Coral1]
\psset{linewidth=1.5pt}
2.5 * cos(t) | 2.5 * sin(t) | t/5}
\psset{border=1.5pt}
2.5 * cos(t) | 2.5 * sin(t) | t/5}
2.5 * cos(t) | 2.5 * sin(t) | t/5}
2.5 * cos(t) | 2.5 * sin(t) | t/5}
2.5 * cos(t) | 2.5 * sin(t) | t/5}
\psset{linewidth=0.6pt, linecolor=Coral1}
\pstThreeDLine(0,0,2)(0,0,2.4)
\pstThreeDLine(0,0,3.3)(0,0,5.0)
\pstThreeDLine[linecolor=black, border = 0pt]{-> }(0,0,0)(0, 2.5, 2.79)
\uput[u](1.7,1.6){ $M$}\uput[-120](0,0){$O$}
\pstThreeDDot[linecolor = DarkSeaGreen3](0, 2.5, 2.83)
\pstThreeDDot(0,0,0)
\end{pspicture}

\end{document}


A solution completely made with TikZ. I used the styles thick and >=stealth' (from the arrows library) in both pictures to make them look fancier. This is of course completely optional.

\documentclass[tikz]{standalone}
\usepackage{tikz,bm}
\usetikzlibrary{angles,arrows,calc,quotes}
\begin{document}
\begin{tikzpicture}[
thick,>=stealth',
declare function = {
logx(\a,\b,\r) = \a*exp(-\b*\r)*cos(deg(\r));
logy(\a,\b,\r) = \a*exp(-\b*\r)*sin(deg(\r));
},
point/.style={draw,thick,circle,inner sep=1pt,label={#1}},
plot/.style={blue,smooth,samples=100}
]
% Spiral parameters
\def\a{5}
\def\b{.2}
% Axes
\draw[->] (-4.5,0) -- (6,0) coordinate[label={below:$x$}] (A);
\draw[->] (0,-3) -- (0,5) node[left] {$y$};
% Spiral
\draw[plot] plot[domain=0:25] ({logx(\a,\b,\x)},{logy(\a,\b,\x)});
% Points M, O and M(t=0)
\coordinate[label={below right:$O$}] (B) at (0,0);
\node[point={above:$M$}] (C) at ({logx(\a,\b,.7)},{logy(\a,\b,.7)}) {};
\node[below] at ({logx(\a,\b,0)},{logy(\a,\b,0)}) {$M(t=0)$};
% Angle
\draw pic[->,draw,"$\varphi$",angle radius=1.5cm] {angle};
% Unit vectors
\draw[->] (B) -- ($(B)!1.3!(C)$)       node[below right] {$\bm{e}_r$};
\draw[->] (C) -- ($(C)!-1.5cm!90:(B)$) node[above right] {$\bm{e}_\theta$};
\draw[->] (B) -- +(1,0)                node[below]       {$\bm{e}_x$};
\draw[->] (B) -- +(0,1)                node[left]        {$\bm{e}_y$};
\end{tikzpicture}

\begin{tikzpicture}[
x={(-.707cm,-.353cm)},y={(1cm,0cm)},z={(0cm,1cm)},
thick,>=stealth',
plot/.style={blue,smooth,samples=100}
]
% Origin and axes
\coordinate[label={above left:$O$}] (O) at (0,0,0);
\draw[->] (O) -- (2,0,0) node[above left] {$x$};
\draw[->] (O) -- (0,2,0) node[above] {$y$};
\draw[->] (O) -- (0,0,4) node[right] {$z$};
% Plot
\draw[plot] plot[domain=0:16] ({cos(deg(\x))},{sin(deg(\x))},{.25*\x});
% Arrow to M
\draw[->] (O) -- ({cos(deg(8))},{sin(deg(8))},2) node[right] {$M$};
\end{tikzpicture}
\end{document}


• How do you do to extract the picture with a transparent background? Can you give me a link about? Oct 26 '14 at 21:59
• I use Windows 7 64b OS, MiKTeX 2.9, I have installed Inkscape. Oct 26 '14 at 22:01

I plotted your functions using pgfplots.

% pdflatex
\documentclass[margin=2mm]{standalone}
\usepackage{tikz}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
\pgfmathdeclarefunction{F}{3}{\pgfmathparse{#1* exp(#2*#3)}}
\begin{axis}
[
smooth, grid=both,minor tick num=1,
xlabel=$x$,ylabel=$y$,
tick align=inside,
samples=1000,
samples y=0,
]

\end{axis}
\end{tikzpicture}
~
\begin{tikzpicture}
\pgfmathdeclarefunction{F}{3}{\pgfmathparse{#1* exp(#2*#3)}}
\begin{axis}
[smooth, grid=both,minor tick num=1,
xlabel=$x$,ylabel=$y$,zlabel=$z$,
samples=1000,
samples y=0,
]

[solid, thick, black,
mark=none,
thick,
domain=0:10*pi,
]
({F(5,-0.1,x)*cos(deg(x))},{F(5,-0.1,x)*sin(deg(x))},{F(5,-0.1,x)});
\end{axis}
\end{tikzpicture}
\end{document}


• Why is necessary put \pgfplotsset{compat=...}? Oct 26 '14 at 21:56