Troubleshooting Latex/Gnuplot Issues

In summary, the symbols in the ps document, don't show up properly in the final document after the latex source is compiled.
  • #1
NeoDevin
334
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
  • #2
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.
 
  • #3
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}
 
  • #4
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
 
  • #5
What file extension should I use for pstricks? it tells me that .ps unrecognized when I try to pdflatex it.
 
Last edited:
  • #6
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.
 
  • #7
Thanks muchly, I will look into those packages and see what I find, I was trying to include it with \includegraphics commands. Silly me.
 
  • #8
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...
 
  • #9
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?
 

1. What are some common causes of errors when using Latex and Gnuplot together?

Some common causes of errors when using Latex and Gnuplot together include incorrect syntax or formatting in the Latex or Gnuplot code, missing or incorrect packages, incompatible versions of Latex or Gnuplot, and using the wrong type of file for input or output.

2. How can I troubleshoot errors when my Latex document is not compiling with Gnuplot plots?

To troubleshoot errors when your Latex document is not compiling with Gnuplot plots, you can try checking the log file for any error messages or warnings, making sure all necessary packages are installed, and ensuring that the Gnuplot code is valid and compatible with your Latex document.

3. What should I do if my Gnuplot plots are not showing up in my Latex document?

If your Gnuplot plots are not showing up in your Latex document, you can first check the log file for any error messages or warnings, make sure the Gnuplot code is valid and compatible with your Latex document, and ensure that the output file type is correct. Additionally, you can try recompiling the document or refreshing the plot cache.

4. How can I fix formatting issues with my Gnuplot plots in Latex?

To fix formatting issues with Gnuplot plots in Latex, you can try adjusting the size and position of the plot within the document, changing the formatting options in the Gnuplot code, and checking for any conflicting packages or settings in your Latex document.

5. What are some tips for avoiding common Latex and Gnuplot issues?

To avoid common Latex and Gnuplot issues, it is important to carefully check for any errors or warnings in the log file, make sure all necessary packages are installed and up to date, and double-check the syntax and formatting of your Latex and Gnuplot code. It can also be helpful to use a template or example code as a guide when first starting to use Latex and Gnuplot together.

Similar threads

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