7

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!

\begin{tikzpicture}
\begin{axis}[domain=-10:10,view={0}{90}] 
\addplot3[contour gnuplot={number=15,labels=false},thick]  {(y^2)/2-cos(x)};
\end{axis}
\end{tikzpicture}
  • 1
    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
  • PGFPlots uses degrees, so your domain is too small. – Jake Oct 26 '13 at 7:12
7

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

\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
\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))};
\end{axis}
\end{tikzpicture}
\end{document}
  • 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 '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
  • 2
    @Herbert I have fixed it in the developer version. – Christian Feuersänger Oct 27 '13 at 18:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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