Skip to content

Instantly share code, notes, and snippets.

@windstriver
Created August 30, 2015 01:32
Show Gist options
  • Save windstriver/29a15f7abc1d5e192380 to your computer and use it in GitHub Desktop.
Save windstriver/29a15f7abc1d5e192380 to your computer and use it in GitHub Desktop.
An example of parametric plot using TikZ from *TikZ & PGF Manual*.
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale=2]
\draw[gray,very thin] (-1.9,-1.9) grid (2.9,3.9)
[step=0.25cm] (-1,-1) grid (1,1);
\draw[blue] (1,-2.1) -- (1,4.1); % asymptote
\draw[->] (-2,0) -- (3,0) node[right] {$x(t)$};
\draw[->] (0,-2) -- (0,4) node[above] {$y(t)$};
\foreach \pos in {-1,2}
\draw[shift={(\pos,0)}] (0pt,2pt) -- (0pt,-2pt) node[below] {$\pos$};
\foreach \pos in {-1,1,2,3}
\draw[shift={(0,\pos)}] (2pt,0pt) -- (-2pt,0pt) node[left] {$\pos$};
\fill (0,0) circle (0.064cm);
\draw[thick,variable=\t,domain=0.1:3.5,samples=500]
% The plot is reparameterised such that there are more samples
% near the center.
plot ({\t*sin((1/\t) r)},{\t*cos((1/\t) r)})
node[right] {$\bigl(x(t),y(t)\bigr) = (t\sin \frac{1}{t}, t\cos \frac{1}{t})$};
\fill[red] (0.63662,0) circle (2pt)
node [below right,fill=white,yshift=-4pt] {$(\frac{2}{\pi},0)$};
\end{tikzpicture}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment