2

I am trying to position a parametric curve within a tikzpicture.
Using the following code, I the curve is plotted with the centre at (0,0), but I would like the centre to be positioned at (0,5) so that the parametric curve touches the circle. I've looked up plot in the tikz documentation; using \addplot from pgfplots; positioning at nodes and paths, all to no avail, the curve remains with centre (0,0)

\documentclass{standalone}

\usepackage{tikz}

\begin{document}
%
\begin{tikzpicture}
%
\draw (0,0) circle [radius=10];
%
\draw [domain=0:360, samples=300] plot ({-5 * sin(\x) * (sin(\x/2))^1.2 }, {-5 * cos(\x)});
%
\end{tikzpicture}
%
\end{document}

How can I specify where the centre of the plot is?

1

Solution 1: Add (0,5) to the plot (note the number 5 starting the y coordinate of the plot).

\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw (0,0) circle [radius=10];
\draw [domain=0:360, samples=300]
  plot ({-5 * sin(\x) * (sin(\x/2))^1.2 }, {5-5 * cos(\x)});
\end{tikzpicture}
\end{document}

Solution 2: Shift the center of the circle down by 5.

\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw (0,-5) circle [radius=10];
\draw [domain=0:360, samples=300]
  plot ({-5 * sin(\x) * (sin(\x/2))^1.2 }, {-5 * cos(\x)});
\end{tikzpicture}
\end{document}

Solution 3: Use a scope and shift its contents, either the circle or the plot.

\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw (0,0) circle [radius=10];
\begin{scope}[shift={(0,5)}] % or [yshift=5cm]
  \draw [domain=0:360, samples=300]
    plot ({-5 * sin(\x) * (sin(\x/2))^1.2 }, {-5 * cos(\x)});
\end{scope}
\end{tikzpicture}
\end{document}

All solutions yield the same picture.

enter image description here

  • thanks, fiddling with tikz made me forget about the most basic of transformations! – Utumno Jan 29 '17 at 20:08

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.