Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

So I am trying to create a plot of an astroid in pgfplots which has the parameterization x = cos(t)^3 y= sin(t)^3 and tikz is giving me an error that it is giving up on a path and wondering if I forgot a semicolon, but I did not.

Any ideas of how I can fix this? Any help is appreciated.

MWE:

\documentclass{minimal}
\usepackage{pgfplots}
\usepackage{tikz}

\pgfplotsset{compat=1.10}

\begin{document}

\begin{tikzpicture}
\begin{axis}[axis x line =middle, axis y line = middle,thick, smooth]
    \addplot[domain=0:2*pi](cos(deg(x)),x);  %this line works like a charm
    \addplot[domain=0:2*pi](x,sin(deg(x)));  %this line does not work
    \addplot[domain=0:2*pi]((cos(deg(x)))^3,(sin(deg(x)))^3); %goal
\end{axis}
\end{tikzpicture}

\end{document}
share|improve this question
1  
use {} : \addplot[domain=0:2*pi]({cos(deg(x))^3},{sin(deg(x))^3}) ; –  Vincent Nivoliers Jun 3 at 15:44
    
@VincentNivoliers yes that worked exactly! why does it need braces here when other parameterizations don't? –  ian Jun 3 at 15:47
    
from the manual, page 53, it has to do with the fact that you use round braces in the expression, and that round braces are already used to enclose the list of coordinates. This is therefore probably due the the parser used for mathematical expressions. –  Vincent Nivoliers Jun 3 at 15:55
2  
@VincentNivoliers, please convert your comment to an answer if it has resolved OP's problem. –  Pouya Jun 3 at 20:36

1 Answer 1

You should use {} : \addplot[domain=0:2*pi]({cos(deg(x))^3},{sin(deg(x))^3}) ;

As said in the comments, this seems to be due to the handling of round braces by pgfplot. See the manual page 53.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.