# Tikz picture of limaçon

How would I create a TikZ picture of the limaçon $r=0.5+\cos(\theta)$?

Would I have to convert it to cartesian coordinates or is there a way to plot the polar form?

• If you're graphing in a cartesian system, see this. – David Mitra May 28 '15 at 20:45

\documentclass[border=5mm]{standalone}

\usepackage{pgfplots}
\usepgfplotslibrary{polar}
\pgfplotsset{compat=1.10}

\begin{document}
\begin{tikzpicture}
\begin{polaraxis}[enlargelimits=false, xticklabel=$\pgfmathprintnumber{\tick}^\circ$]
\addplot [thick, red, domain=0:360, samples=100] {.5+cos(x)};
\end{polaraxis}
\end{tikzpicture}
\end{document}


For those who are interested, here is a MetaPost version of Friendly Ghost's nice answer. I've found it an interesting exercise to reproduce it. It uses a plr_function macro defined in the preamble, which draws the plot of a polar function given as argument.

The MetaPost code has been inserted in a LuaLaTeX program here (MetaPost being kind of integrated into LuaTeX), but it is by no means necessary: it is only easier to typeset it this way, since not everyone knows how to run standalone MetaPost.

\documentclass[border=2mm]{standalone}
\usepackage{gensymb, luamplib}
\mplibsetformat{metafun}
\mplibtextextlabel{enable}
\everymplib{u := 2cm;
vardef plr_function(expr tmin, tmax, tstep)(text f_t) =
save t; t := tmin;
(f_t)*dir t forever: hide(t := t + tstep) exitif t > tmax;
.. (f_t)*dir t endfor
if t - tstep < tmax: hide(t := tmax) .. (f_t)*dir t fi
enddef;
beginfig(1);}
\everyendmplib{endfig;}
\begin{document}
\begin{mplibcode}
for i =  1 upto 3:
draw fullcircle scaled (i*u) withcolor .8white;
label.bot("$" & decimal .5i & "$", (.5i*u, 0));
endfor
for i = 0 upto 11:
draw origin -- 1.6u*dir 30i withcolor .8white;
freelabel("$" & decimal 30i & "\degree$", 1.6u*dir 30i, origin);
endfor
draw plr_function(0, 360, 1)(.5 + cosd t) scaled u withcolor red;
\end{mplibcode}
\end{document}


Output: