GNUPlot generated EPS figure in latex

In summary, you can use graphicx to import your .eps graphics, regenerate the pdf if necessary, and then use pstricks to put your vector graphics on top.
  • #1
mzh
64
0
Dear Forum
I would like to establish a workflow of how to include .eps graphics generated with gnuplot into Latex documents and it would be great if other could contribute to this.
At the moment its like this. I plot some data with gnuplot and save it to a .eps file. However, the "white-space" margin to the left and right are too large (so placing to figures next to each other looks bad).
First question: What is the smartest way of generating a bounding box that does not include so much white space? Of course, I can edit the eps file, but still, doing it for 5, 10 or more files is impractical.
Second question: what latex compiler do I need to be able to compile the document with the eps figures? PDFLATEX does not work, it requires PNGs or PDFs. So i need to convert the eps files first to pdfs, which is also impractical to do everytime I need to change a label.
Third question: How can PNGs be combined with vector graphics in the same latex document?

So, I really would like to establish this for me now once and for all. Maybe its also usefull to others.

Thanks for your feedback.
 
Physics news on Phys.org
  • #2
Consult for example http://en.wikibooks.org/wiki/LaTeX/Importing_Graphics

I use the following packages:
graphicx (for importing raster graphics [I use png and sometimes eps])
pstricks (for fancy vector graphics).
You can use the ordinary picture environment if you don't need fancy graphics.

graphicx can display a specified region of your graphics file, effectively cropping for display without altering the original.

In a pspicture or picture environment,
I import the graphics [using includegraphics from graphicx],
then draw my vector graphics on top of it (for example, adding text, symbols, arrows, or other LaTeX graphics). Some trial and error is involved to do the positioning.

Scripting (e.g., with perl or python) can help with repetitive tasks.
I use ImageMagick's identify to help get the pixel dimensions of my graphics files.
I use a perl script to read its output and have it write the includegraphics command with bounding box dimensions and scaling information.
I actually use an additional program to send its output to my clipboard so that I can paste it in my editor.
 
Last edited:
  • #3
mzh said:
Second question: what latex compiler do I need to be able to compile the document with the eps figures? PDFLATEX does not work, it requires PNGs or PDFs. So i need to convert the eps files first to pdfs, which is also impractical to do everytime I need to change a label.
You shouldn't have to reconvert every time you change the label. The label should not be a part of the graphic. Label the figure with the \caption command:

Code:
\begin{figure}
\centering
\includegraphics{name_of_file_containing_graph}
\caption{Caption that gives meaning to the graph}
\label{some_unique_label}
\end{figure}
 
  • #4
@pf mentor: sorry, was not clear here. didnt mean the lable. Rather say the axis or the key/legend of the diagram.
 
  • #5
Why is regenerating the pdf impractical every time you change something in the diagram? After all, you regenerate the .eps file every time you change something in the diagram.

The solution is to script the process. If you are on a Unix derivative, use make. I often use a complex web of programs to create my pdf documents. Some figures are specified as graphviz .dot files that must be processed by dot, others are files that must be processed by gnuplot (and occasionally post-processed by ps2pdf), and so on. Some of those .dot files and gnuplot data files are automatically generated by other programs.

I would be forced to type that entire mess by hand if I didn't have it all scripted. That would be nigh impossible to get right. Fortunately, it is scripted. It can take a while to get the scripts right, but once you have them right they're pretty much static. And portable. One of the projects I work on has thousands of pages of pdf documentation generated by latex. We would be DOA if it weren't for all the scripting magic used to create those documents.
 

1. How do I include a GNUPlot generated EPS figure in LaTeX?

To include a GNUPlot generated EPS figure in LaTeX, you can use the \includegraphics command from the graphicx package. Make sure to specify the correct file path and include the .eps extension.

2. Can I adjust the size of the EPS figure in LaTeX?

Yes, you can adjust the size of the EPS figure in LaTeX using the \includegraphics command. You can specify the desired width and height, or use relative scaling such as \textwidth or \linewidth.

3. How do I add a caption and label to the EPS figure in LaTeX?

To add a caption and label to the EPS figure in LaTeX, you can use the \caption and \label commands. These should be placed after the \includegraphics command, and before the \end{figure} command.

4. Can I change the font and style of the EPS figure in LaTeX?

Yes, you can change the font and style of the EPS figure in LaTeX by using the \psfrag command. This allows you to replace text in the figure with LaTeX code, allowing for consistent font and style throughout your document.

5. How do I make sure the EPS figure stays in the correct position in my LaTeX document?

To ensure the EPS figure stays in the correct position in your LaTeX document, you can use the \begin{figure}[h] command. This will place the figure in the current position in the document, instead of floating to a different page. You can also use the \clearpage command to force the figure to be placed on a new page.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
16
Views
17K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
41K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
6K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
5K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
4K
Back
Top