LaTeX Troubleshooting Latex/Gnuplot Issues

AI Thread Summary
Generating graphs in Gnuplot using the postscript enhanced terminal can lead to issues with symbol display in LaTeX documents, particularly when using the term pslatex, which may cause preview errors. The term latex can also trigger bounding box errors due to the need for encapsulated postscript. To resolve these issues, using the pstricks output in Gnuplot is recommended, as it integrates seamlessly with LaTeX and produces high-quality graphics. Users are advised to utilize the pst-pdf or pdftricks packages instead of the deprecated ps4pdf for better compatibility. For color plotting and adding legends, specific Gnuplot commands can be employed, and resources for further assistance are available online.
NeoDevin
Messages
334
Reaction score
2
I'm generating a graph in gnuplot, using the postscript enhanced terminal setting, and trying to use symbols in the axes labels, then import the ps file into a latex document. The trouble I'm having is that the symbols in the ps document, don't show up properly in the final document after the latex source is compiled. I have tried using term pslatex, but when I use it, it compiles, but then the previewer gives me an error when it tries to show. I tried using term latex, but then the latex compiler complains that there is no bounding box.

Any ideas anyone?
 
Physics news on Phys.org
Not used gnuplot + latex recently but generally tex needs encapsulated postscrpt, this is the cause of the bounding box error.
I don't know if gnuplot can generate eps but ghostview can certainly convert ps->eps.
 
The pstricks output from gnuplot coupled with the pstricks LaTeX package make very beautiful, colored graphs. IMHO, the postscript output is not nearly as nice looking. The pstricks output is native LaTeX. No goofy postscript needed. It works with both the basic latex processor, producing .dvi and .ps files and with pdflatex, which produces .pdf files directly.

As an aside, I much prefer the latter. PDF files generated from postscript files have this ghostly view to them (pun intended). PDF files generated directly via pdflatex take advantage of the PDF bookmark capabilities.

So how to use pstricks? In gnuplot, simply set term pstricks. In your latex document (I am assuming pdflatex here), I use
Code:
\usepackage{graphicx}
\usepackage{ps4pdf}
\PSforPDF{
  \usepackage{pstricks}
}
\usepackage[colorlinks]{hyperref}
 
I almost always do "print screen" to convert the picture from gnuplot to paint or similar and save it as a .png file. I think png-files look up nicer in Latex :P
 
What file extension should I use for pstricks? it tells me that .ps unrecognized when I try to pdflatex it.
 
Last edited:
First things first: Look at the gnuplot/pstricks output file. It's native LaTeX! You simply input them.

I should have looked deeper into a file where I used the packages. All I showed above is the preamble. You have also have to embed each input{pstricks_file} in a PSforPDF macro:
Code:
\begin{figure}
  \centering
  \PSforPDF{
    \input{foobarplot}
  }
  \caption{Foo as a function of bar}
  \label{fig:foobar}
\end{figure}

Some useful websites are CTAN, the Comprehensive TeX Archive Network, at www.ctan.org and TUG, the TeX Users Group, at www.tug.org. The former hosts the searchable TeX catalogue online. Some relevant pages:
  • PSTricks website at tug.org
  • http://www.dante.de/CTAN/graphics/pstricks/base/doc/pstricks-doc.pdf
  • http://www.ctan.org/tex-archive/help/Catalogue/entries/pstricks.html
  • http://www.ctan.org/tex-archive/help/Catalogue/entries/ps4pdf.html
  • A TUGboat paper on ps4pdf

Note that the ps4pdf catalog entry notes that ps4pdf is deprecated and that you should use the pst-pdf or pdftricks package instead. I suggest you look into these as alternatives. However, ps4pdf works quite nicely for me and I don't have to touch the gnuplot output to use it.
 
Thanks muchly, I will look into those packages and see what I find, I was trying to include it with \includegraphics commands. Silly me.
 
please can anyone help me to plot with colors in G N U P L O T
Version 4.0 patchlevel 0, as I found some commands somewhere online, but it does not work, can you plaes show me how to do it, and how to add legends...
 
try:
Code:
set te post enhanced color
should make your output postscript with colour.
 
  • #10
NeoDevin said:
try:
Code:
set te post enhanced color
should make your output postscript with colour.

Really appreciate your time, any further help would be much appreciated actually I have already such a command, what I meant is to set certain colors by these commands s
PHP:
et style line 1 lt 1 lw 6
set style line 2 lt 3 lw 8 pt 7 ps 2
which allows to choose certain color, but is not working with me, also do you any ides how to add a small box which magnify a small part of the figure usually appear in the right top side on the figure
 
  • #11
ANYONE plaes show me how to add the time in Latex presentation and slide number??
 
  • #12
NeoDevin said:
try:
Code:
set te post enhanced color
should make your output postscript with colour.

Please could anyone give me a hand in this...I've been struggling for a while of using GNUPLOT
to plot a file of 3 columns as a contour plot, but it gave me warning
message say {can not contour non grid data}, even I used the command
Code:
 set dgrid3d 10,10, 16
 set dummy u,v
 set parametric
        dummy variable is t for curves, u/v for surfaces
 set contour base
 set style data lines
 splot 'myfile'

cheers
 
  • #13
How can I insert LateX mathematics symbols in a plot with Gnuplot?

I know how to do it using
Code:
set terminal latex
and sending the output on a latex file from gnuplot, but I would like to include symbols directly in a gnuplot file *.plt so that they are shown when I draw the output with gnuplot.
 
  • #14
Hi
have alook at this link, it explains how to add symbols like Greek letters

http://t16web.lanl.gov/Kawano/gnuplot/label-e.html
 
Last edited by a moderator:
  • #15
Do you know how to print in color directly from gnuplot? When I print it only displays BW.
 
  • #16
It is possible to use:

plot for [i=1:10] ...

in parametric plot?
 

Similar threads

Replies
23
Views
4K
Replies
4
Views
5K
Replies
16
Views
17K
Replies
1
Views
3K
Replies
4
Views
4K
Replies
5
Views
3K
Replies
1
Views
7K
Back
Top