Results 1 to 5 of 5

Thread: Placing gnuplot Graphs in LaTeX Files

  1. #1
    Join Date
    May 2008
    Beans
    146

    Placing gnuplot Graphs in LaTeX Files

    Some work I am doing would be vastly clearer if I were able to insert images into the LaTeX file (more specifically, graphs from gnuplot). I've tried Googling the matter, but to no avail. What image format would be best to use for the graph, how would I have gnuplot output a graph in this format and how would I embed the resulting file into the LaTeX file?

  2. #2

    Re: Placing gnuplot Graphs in LaTeX Files

    Gnuplot can output graphics to the .eps format (encapsulated postcript).

    You can use it directly in LaTeX, unless you use pdflatex to create the document.

    If this is the case, use epstopdf to convert the .eps graph to an .pdf file.

    With the .pdf graph and the pdflatex you can insert it like this:

    \begin{figure}[htpb]
    \begin{center}
    \includegraphics[scale=1]{graph-file}
    \end{center}
    \caption{some text here}
    \label{Another text here}
    \end{figure}

  3. #3
    Join Date
    Aug 2006
    Location
    Santa Fe, NM
    Beans
    892
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Re: Placing gnuplot Graphs in LaTeX Files

    AFAIK You cannot include eps files if you use pdflatex to create your pdf from your latex files, however if you use pdflatex you can include png files. Thats one choice you will have to make..

    Eps -> Latex -> Dvipdf
    Png -> Pdflatex

    Now inside gnuplot you have to tell it to output to whatever format you want. I usually go with eps (they tend to look better when scaling, for me at least). This is the command I give.

    Code:
    set term pos eps color enhanced defaultplex "Helvetica" 26
    After this you would set your output file like this
    Code:
    set output 'Graph.eps'
    And then you can go ahead and plot as normal. Now instead of being able to see the plot, it will just create a file for you called Graph.eps. You can view this is evince if you want to see what it looks like.

    Also, there is a terminal option called epslatex, using this gnuplot will create an eps of the graph, as well as a latex file that you can just include (or copy the contents of) to put the graph into a document.

  4. #4
    Join Date
    May 2008
    Beans
    146

    Re: Placing gnuplot Graphs in LaTeX Files

    Brilliant, that got the graphs in. Is it possible to have the graph in the .eps file centred, though? As it is, the graph is a fair bit off-centre, which looks a bit odd in the .dvi.

  5. #5
    Join Date
    May 2009
    Beans
    4

    Re: Placing gnuplot Graphs in LaTeX Files

    Thanks favi that worked like a charm.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •