I created the following plot in Gnuplot by fitting a gaussian curve to some data. In Gnuplot it looks like this: plot in Gnuplot

It doesn't look perfect but that is totally fine.

I used

set terminal latex
set output "output.tex"

to create a .tex file which I included in LaTeX by using


but when I import it into my LaTeX document in TeXstudio it looks like this plot in TeXstudio

How can I make the plot look better? I couldn't make the markers for the data points disappear nor could I change the fit from dots to a line. Since it looks completely different in Gnuplot I don't really know what I am doing wrong. I tried using stuff like "with dots" etc. but then I don't have any errorbars at all.

  • I think the latex terminal uses the picture environment to generate the plot, but this is very limited. Try using the epslatex terminal instead. This creates an eps image, and uses the picture environment to add labels etc. It produces much better results. Nov 26, 2017 at 20:18

1 Answer 1


I like using the cairolatex terminal for gnuplot. This is similar to the epslatex terminal because it generates a picture without any labels and an accompanying TeX file which includes the picture and writes the labels on top. The cairolatex terminal is superior to the epslatex terminal because it allows to save the picture as PDF instead of EPS which then does not need shell-escaping for conversion before including.

In a gnuplot file you'd use it as follows:

#!/usr/bin/env gnuplot

set terminal cairolatex pdf
set output 'plot.tex'

set format '$%g$'

set xlabel '$x$ in mm'
set ylabel '$N$' rotate by 0

set samples 1000

set yrange [-.1:1.1]

plot exp(-x**2) title '$\exp(-x^2)$'

And in the LaTeX document you simply include the output:




enter image description here

The plot I showed above is not very sophisticated but you can do really nice things with cairolatex. Click here for an example from a document of mine.

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.