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.

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)};
share|improve this question
is it (y^2)/2 - cos(x) or y^(2/(2-cos(x))) or is it [1/(2-cos(x))]y^2 –  Nicholas Hamilton Oct 26 '13 at 2:24
@ADP Thanks! (y^2)/2 - cos(x). –  Eden Harder Oct 26 '13 at 2:28
PGFPlots uses degrees, so your domain is too small. –  Jake Oct 26 '13 at 7:12

1 Answer 1

up vote 8 down vote accepted

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))};
share|improve this answer
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 –  Herbert Oct 26 '13 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. –  Christian Feuersänger Oct 27 '13 at 18:21
@Herbert I have fixed it in the developer version. –  Christian Feuersänger Oct 27 '13 at 18:52

Your Answer


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.