please look at the following MWE:




\draw[color=blue] plot[raw gnuplot, smooth] function{
splot sin(x)*sin(y)};


I try to plot a function of 2 variables, but I get a very strange output:

enter image description here

It should be similar to the output in Gnuplot:

enter image description here

Where is my mistake? (I know I could use pgfplots, but I look for a solution without.)

  • I see that you are saying that you do not want to use pgfplots but it takes care of a lot of things you need to do by hand without. I am not sure how to tell gnuplot the domains, the view angles, the plot variables and so on out of the top of my head, but pgfplots wold take care of it. See here for a related discussion.
    – user121799
    Jun 11, 2019 at 17:10
  • It's not all that strange, it's the same as the output from Gnuplot viewed from above, I think (try \begin{axis}[view={0}{90}] \addplot3[raw gnuplot, smooth] function{ splot sin(x)*sin(y)}; \end{axis}, then remove the view and try again). I don't TikZ does 3D plots, which CarpeDiemKopi's answer below also suggests. Jul 27, 2019 at 7:24

4 Answers 4


According to the current manual TikZ PGF Packages Manual 3.1.4 with status from July 17, 2019 TikZ simply cannot read 3D GNUPLOT table files and that explains why you get a very strange output. By the way, this output changes with the scale factor.

22.4 Plotting Points Read From an External File
Currently, the only file format that TikZ allows is the following: Each line of the〈filename〉should contain one line starting with two numbers, separated by a space. A line may also be empty or, if it starts with # or % it is considered empty. For such lines, a “new data set” is started, typically resulting in a new subpath being started in the plot (see Section 112.2.2 on how to change this behaviour, if necessary). For lines containing two numbers, they must be separated by a space. They may be following by arbitrary text, which is ignored, except if it is o or u.
(This is exactly the format that gnuplot produces when you say set terminal table.)

With the restriction...if you command: plot

But you want this with 3 numbers from 'splot':

# Surface 0 of 1 surfaces
# Curve title: "sin(x)*sin(y)"
# IsoCurve 0, 100 points
# x y z type
-10.00000 -10.00000 0.29596 i
-9.79798 -10.00000 0.19835 i
-9.59596 -10.00000 0.09267 i
-9.39394 -10.00000 -0.01677 i

marmot only used plot (2D) in his answer and thus avoided this problem.

One question now is why you don't want to use PGFPLOTS. It can replace or supplement GNUPLOT. The replacement is an \addplot expression which evaluates the expressions using the math parser of PGF while \addplot gnuplot employs GNUPLOT to compute the coordinates.

\addplot3[raw gnuplot,smooth] gnuplot[id=sinus3d] {splot sin(x)*sin(y)};

There are some more options to control the GNUPLOT interaction. For more details see SE question: PGFplots and GNUplot with addplot3, an MWE with 9 lines and pay attention to the comments from Christian Feuersänger.

Bottom line:
TikZ cannot currently understand GNUPLOT 3D plots without additional packages.


I have no idea how to steer splot from TikZ only. The following produces something reminiscent of the screen shot you seem to be looking for,

\foreach \Y in {-10,-9,...,10}
\draw[color=blue] plot[raw gnuplot,smooth] 
function{plot sin(x)*sin(\Y)};

enter image description here

but obviously there are tons of things that could be improved, starting from an orthonormal projection.


What about knitr?


fsinsin <- function (x, y) {return (sin(x)*sin(y))}
x <- seq(-6, 6, length= 40)
y <- x
z <- outer(x, y, fsinsin)
trellis.par.set("axis.line", list(col=NA,lty=1,lwd=1))
wireframe(z, drape=T, shade=F, xlab="x", ylab="y",
col.regions=rainbow(150), aspect = c(1, .2), borders=F,
scales = list(arrows = FALSE),


What about using the gnuplottex package with the tikz output terminal (page 9, gnuplottex.pdf)?

Furthermore, if you have many pictures the tikz-package offers the possibility to externalize the pictures, see p. 11 gnuplottex.pdf.


enter image description here


            set out "tex-gnuplottex-fig1.tex"
            set term lua tikz latex createstyle
            splot sin(x)*sin(y);
        \caption{This is using the \texttt{tikz}-terminal. The function $f(x,y)=sin(x)*sin(y)$}%

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.