Troubleshooting Latex/Gnuplot Issues

  • Context: LaTeX 
  • Thread starter Thread starter NeoDevin
  • Start date Start date
  • Tags Tags
    Issues Troubleshooting
Click For Summary

Discussion Overview

The discussion revolves around troubleshooting issues related to using Gnuplot with LaTeX, particularly focusing on generating graphs with proper formatting, symbol usage, and color output. Participants explore various terminal settings, file formats, and packages to resolve these issues.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant describes issues with symbols not displaying correctly in LaTeX after importing a PostScript file generated by Gnuplot.
  • Another participant suggests that the bounding box error may stem from the need for encapsulated PostScript (EPS) files, noting that Gnuplot may not generate EPS directly but Ghostview can convert PS to EPS.
  • A participant advocates for using PSTricks with Gnuplot for better visual quality in LaTeX documents, providing specific LaTeX package recommendations and usage instructions.
  • One user mentions a preference for converting Gnuplot outputs to PNG files for better appearance in LaTeX.
  • Another participant inquires about the correct file extension for PSTricks, indicating an issue with pdflatex not recognizing .ps files.
  • A participant clarifies that Gnuplot's PSTricks output is native LaTeX and should be included using specific macros.
  • Several participants discuss commands for setting colors in Gnuplot and express difficulties in implementing specific styles and legends in their plots.
  • One user seeks assistance with adding time and slide numbers in LaTeX presentations.
  • Another participant raises a question about contour plotting in Gnuplot and receives suggestions for commands to use.
  • A user asks how to insert LaTeX mathematical symbols directly in Gnuplot files, while another provides a link for guidance on adding symbols.
  • One participant inquires about printing in color directly from Gnuplot, noting that their output is only in black and white.
  • A question is posed regarding the use of parametric plots with a specific Gnuplot syntax.

Areas of Agreement / Disagreement

Participants express various methods and preferences for using Gnuplot with LaTeX, with no consensus reached on the best approach. Multiple competing views and unresolved issues remain regarding file formats, terminal settings, and specific commands.

Contextual Notes

Some limitations include the dependence on specific Gnuplot versions, the need for correct file formats, and the potential for errors in LaTeX compilation that are not fully resolved in the discussion.

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 ·
Replies
23
Views
4K
  • · Replies 5 ·
Replies
5
Views
5K
  • · Replies 4 ·
Replies
4
Views
5K
  • · Replies 11 ·
Replies
11
Views
6K
  • · Replies 16 ·
Replies
16
Views
18K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 1 ·
Replies
1
Views
7K