I want to contour plot the curves (y^2)/2-cos(x)=c with the following code, but there are only straight line in the output figure. What's wrong? Any help or suggestions will be appreciated!

\addplot3[contour gnuplot={number=15,labels=false},thick]  {(y^2)/2-cos(x)};
  • 1
    is it (y^2)/2 - cos(x) or y^(2/(2-cos(x))) or is it [1/(2-cos(x))]y^2 Oct 26, 2013 at 2:24
  • PGFPlots uses degrees, so your domain is too small.
    – Jake
    Oct 26, 2013 at 7:12

1 Answer 1


PGFPlots uses degrees for trigonometric functions, not radians. You can convert your values to degrees using deg(x) instead of just x:


\begin{axis}[domain=-10:10,view={0}{90}, samples=60, samples y=60] 
\addplot3[contour gnuplot={number=15,labels=false},thick]  {(y^2)/2-cos(deg(x))};
  • what is the reason that I get with xelatex a completely other output? I have current TL 2013. My output: perce.de/pub/xelatex.png
    – user2478
    Oct 26, 2013 at 12:02
  • @Herbert thanks for the helpful question. That is a bug; the input file for gnuplot receives ^^I as column separator; but that does not seem to work in xelatex (which generates three separate chars). I will take care of it. Oct 27, 2013 at 18:21
  • 2
    @Herbert I have fixed it in the developer version. Oct 27, 2013 at 18:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .