2

I am trying to plot the following:

\documentclass[tikz, convert = false]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat = 1.9}

\begin{document}
\begin{tikzpicture}
  \begin{axis}[view = {70}{30}]
    \addplot3[raw gnuplot, surf]
    gnuplot[id = surf] (x, {1/x*cos(deg(y))}, {1/x*sin(deg(y))});
  \end{axis}
\end{tikzpicture}
\end{document}

I only receive a 2d blank axis back. I am not that familiar with using gnuplot with addplot3, so I am under the impression I am not calling gnuplot correctly in this case.


With Henri Menke's solution, we do get a plot but it isn't correct. Here is a correct plot without using gnuplot:

enter image description here

Here is a different angle of Henri's plot where you can see the the issue more clearly.

enter image description here

dustin
  • 18,617
  • 23
  • 99
  • 204

1 Answers1

8

If you want to use the raw gnuplot option, then you have to supply gnuplot code as the plot command.

% arara: pdflatex: {shell: yes}
\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
  \begin{axis}[view={70}{30}]
    \addplot3[raw gnuplot,surf] gnuplot[id=surf] {set parametric; splot[-5:5][-5:5] v,1/v*cos(u),1/v*sin(u)};
  \end{axis}
\end{tikzpicture}
\end{document}

enter image description here

Henri Menke
  • 109,596
  • This method did get it to work but the plot is incorrect. I will edit my question to show the issue. – dustin Apr 23 '14 at 11:20
  • @dustin That is a problem with the sorting of the z-values. I also have tried this several times and didn't get it to work properly. I will again have a look into this. – Henri Menke Apr 23 '14 at 13:31
  • Not problem. Maybe the two contrasting diagrams will draw more interest as well. – dustin Apr 23 '14 at 13:35
  • Pgfplots tries to apply the standard z ordering as for a normal matrix plot. Writing z buffer=sort will repair it for every view angle. – Christian Feuersänger Apr 23 '14 at 16:32
  • @ChristianFeuersänger z buffer = sort didn't solve the problem. – dustin Apr 24 '14 at 16:35
  • Well, it solves the problem of z sorting. There is still a problem with the plot domain. It seems to me that the gnuplot argument splot[0:2*pi][0.2:5] solves it. Alternatively, you could use \addplot3[surf,domain=0.2:5,domain y=0:2*pi] (x,{1/x*cos(deg(y))},{1/x*sin(deg(y))}); which also solves it. Note that the gnuplot solution currently ignores the samples option of pgfplots and uses its own sampling density. – Christian Feuersänger Apr 24 '14 at 17:59