4

I would like to plot implicit functions in Latex with tikz and gnuplot. A minimal example of my code is given by:

\documentclass{article}
  \usepackage{tikz}
\begin{document}
  \begin{tikzpicture}[xscale=1,yscale=.25]
    \draw plot[id=curve, raw gnuplot] function{
      f(x,y) = y**2 + (x**2 - 5)*(4*x**4 - 20*x**2 + 25);
      set xrange [-4:4];
      set yrange [-15:15];
      set view 0,0;
      set isosample 1000,1000;
      %set size square;
      set cont base;
      set cntrparam levels incre 0,0.1,0;
      unset surface;
      splot f(x,y)
    };
  \end{tikzpicture}
\end{document}

This generates the following ugly output. I expected to get a smooth plot. Output generated by the code

The problem occured with MikTex 2.9 on Windows 7. The version of pgf is 3.0.0 according to the Miktex Package Manager and 2.10 according to the command \pgfversion. I assume the "correct" version number to be 3.0.0 since the files in my pgf directory where modified for the last time on 2013-12-13, this is the same day as the modification date of the 3.0.0 version on Sourceforge (http://sourceforge.net/projects/pgf/files/pgf/)

I also tried to compile the document on Ubuntu with \pgfversion 2.10. This generated the same result as on Windows.

The same problem occured here:

How to use the results of `raw output` to create a smooth plot

The problem described in the above post should be solved since 2013-07-31, see:

http://sourceforge.net/p/pgf/bugs/149/#e1ce

In the SO question Pieter furthermore proposes a hackish solution, I tried this, but it did not change the plot.

Thanks for your help!

  • I get this with miktex: i.stack.imgur.com/UHnJ6.png – user11232 Sep 12 '14 at 22:40
  • \pgfversion gives me 3.0.0 with current TeX Live. You probably need to figure out how to update. Note that you could have two versions installed with the older one being found first when you compile. However, I don't know enough about MiKTeX or Windows to say. – cfr Sep 13 '14 at 1:06
3

Thanks to the helpful comments I figured out that the problem to solve was to get pdflatex use version 3.0.0 of pgf.

Since the Miktex Package Manager said, that I had installed version 3.0.0 and the pgf package was not updatable, but \pgfversion displayed version 2.1 I think my MikTex installation was (for an unknown reason) broken. Therefore I decided to uninstall and reinstall Miktex.

This solved my problem. I now get the expected output, as posted by Harish Kumar:

Correct output of the code

  • I don't say thank you. The comments to my question (not the one answer, which I consider offtopic) gave me a hint how to solve the problem by myself. I thougt it would be nice to document this solution for other people with the same problem. If this is unwanted, please delete the answer again. – Daniel Homann Sep 13 '14 at 11:42
3

Just for fun solution with PSTricks.

\documentclass[pstricks,border=15pt,12pt]{standalone} 
\usepackage{pst-func} 

\begin{document} 
\begin{psgraph}[Dy=2](0,0)(-3,-12)(3,12){12cm}{12cm}
    \psplotImp[algebraic,linecolor=red,stepFactor=.3](-2.5,-12)(2.5,12){y^2 + (x^2-5)*(4*x^4-20*x^2+25)}
\end{psgraph}
\end{document}

enter image description here

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.