# tikz and polar plot

I am completely lost with this problem : I want to plot some polar curve. Here is something that works :

\begin{center}
\begin{tikzpicture}[xscale=1,yscale=1]
\draw[thick,->,>=latex] (-2,0)--(2.5,0) node[above] {$x$};
\draw[thick,->,>=latex] (0,-2)--(0,2) node[left] {$y$};
\draw[domain=0:540,scale=1.5,samples=500] plot (\x:{cos(\x/3)*cos(\x/3)*cos(\x/3)});
\end{tikzpicture}
\end{center}


But if I do almost the same, namely :

\begin{center}
\begin{tikzpicture}[xscale=1,yscale=1]
\draw[thick,->,>=latex] (-2,0)--(2.5,0) node[above] {$x$};
\draw[thick,->,>=latex] (0,-2)--(0,2) node[left] {$y$};
\draw[domain=0:3*pi,scale=1.5,samples=500] plot (\x:{cos(\x/3 r)*cos(\x/3 r)*cos(\x/3 r)});
\end{tikzpicture}
\end{center}


or even :

\begin{center}
\begin{tikzpicture}[xscale=1,yscale=1]
\draw[thick,->,>=latex] (-2,0)--(2.5,0) node[above] {$x$};
\draw[thick,->,>=latex] (0,-2)--(0,2) node[left] {$y$};
\draw[domain=0:3*pi,scale=1.5,samples=500] plot (\x:{cos(\x/3*180/pi)*cos(\x/3*180/pi)*cos(\x/3*180/pi)});
\end{tikzpicture}
\end{center}


the last two don't work. I have no clue why Tikz cannot accepet the radian with the previous two.

Also, if anyone can tell me how to avoid to write three times the cosine to make it as cube, that'd be great. I tried several syntaxes, but none of them worked.

What is for me very strange is that I ploted some polar curve before, and for example this syntax worked fine :

\begin{center}
\begin{tikzpicture}[xscale=0.5,yscale=30]
\fill[pattern=north east lines]
plot [domain=-pi/4:0,scale=3,samples=500] (\x:{-2*cos(2*\x r)/cos(\x r)})%
-- plot [domain=0:pi/4,scale=3,samples=500] (\x:{-2*cos(2*\x r)/cos(\x r)})%
-- cycle ;
\draw[thick,->,>=latex] (-8,0)--(8,0) node[above] {$x$};
\draw[thick,->,>=latex] (0,-0.05)--(0,0.15) node[left] {$y$};
\draw[thick,dotted] (6,-0.12)--(6,0.13);
\draw (-6,0) node[below left] {$-a$};
\draw (6,0) node[below right] {$a$};
\draw[domain=-pi/2.4:pi/2.3,scale=3,samples=500] plot (\x:{-2*cos(2*\x r)/cos(\x r)});
\end{tikzpicture}
\end{center}


I would appreciate any comment !

-

When using polar coordinates the angle is a value in degrees, but you supply an angle in radians. Use {deg(\x)} to convert \x to degrees. For the cube you can use cos(\x r)^3.

\documentclass[tikz,border=2mm]{standalone}
\begin{document}
\begin{tikzpicture}
\draw[thick,->,>=latex] (-2,0)--(2.5,0) node[above] {$x$};
\draw[thick,->,>=latex] (0,-2)--(0,2) node[left] {$y$};
\draw[domain=0:540,scale=1.5,samples=500] plot (\x:{cos(\x/3)^3});
\end{tikzpicture}

\begin{tikzpicture}
\draw[thick,->,>=latex] (-2,0)--(2.5,0) node[above] {$x$};
\draw[thick,->,>=latex] (0,-2)--(0,2) node[left] {$y$};
\draw[domain=0:3*pi,scale=1.5,samples=500] plot ({deg(\x)}:{cos(\x/3 r)^3});
\end{tikzpicture}

\end{document}

-
I see about degree, but why in that case does my last example work ? Also, I did try what you suggest for the cube. After seeing your answer I tried again, and it still doesn't work. Here is my preamble, maybe I forgot but I don't see what : –  antoine Apr 2 '14 at 18:02
\usepackage{amssymb,amscd,amsmath,amstext,amsfonts,stmaryrd} \usepackage[francais]{babel} \usepackage[latin1]{inputenc} \usepackage[T1]{fontenc} \usepackage{fancyhdr} \usepackage[french]{minitoc} \usepackage{slashbox} \usepackage{a4wide} \usepackage{array} \usepackage{theorem} \usepackage{enumerate} \usepackage{lastpage} \usepackage{pict2e} \usepackage[babel=true,kerning=true]{microtype} \usepackage{tikz,xcolor} \usepackage{fancybox} \usepackage{mathrsfs} \usepackage{blkarray} \usepackage{mathabx} \usepackage{shortlst} \usepackage{tabularx} –  antoine Apr 2 '14 at 18:04
Last thing ! If you use {deg(\x)}, why do you have to put the "r" inside the cosine ? –  antoine Apr 2 '14 at 18:33
@antoine Which version of pgf/TikZ do you have? I have 3.0. Add \listfiles before \documentclass to get a list of all packages and their versions printed near the end of the .log file. For the last question: The cos function uses degrees, when you add  r it uses radians instead. You could have said plot ({deg(\x)}:{cos(deg(\x/3))^3}) as well, same thing. –  Torbjørn T. Apr 2 '14 at 22:06
@antoine Not sure about that last example. –  Torbjørn T. Apr 2 '14 at 22:06