[Tex/LaTex] Graphs of Implicit Curves using Tikz, gnuplot, and LaTeXIt

gnuplotlatexittikz-pgf

I need to create .png files of graphs that I create. Specifically, the graphs need to have a transparent background.

I have been using LaTeXIt to compile my tikz code, and it has worked well. However, I then ran into the trouble of graphing implicit curves. Doing some research, I came across the idea of calling gnuplot with the "raw gnuplot" option within the tikz code (Note: This means I'm an extreme gnuplot newbie).

This works when I compile the code normally with TeXShop—beautiful implicit curves.

However, the same code put into LaTeXIt fails to produce the curve at all. I assume this is because LaTeXIt is not finding/reading/understanding the .table file that is created.

Does anyone know of a way to get LaTeXIt to work well with tikz code that calls gnuplot?

Below is an MWE of the code that works correctly with TeXShop.

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw plot[id=question1, raw gnuplot, smooth] function{
  f(x,y) = x**4+8*y*y*y-21;
  set xrange [-4:4];
  set yrange [-4:4];
  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}

Best Answer

In order to run gnuplot from within pdflatex, you have to pass the -shell-escape option.

Go to the preferences of LaTeXIt and choose the “Typesetting” tab; next to the pdflatex box there's the icon

enter image description here

Click over it and a window to be filled appears; press the “+” button and complete as in the picture below:

enter image description here

Press “OK” and then all should go well. I defined a template for TikZ and compiled the code:

enter image description here