Gnuplot FAQ
Gnuplot FAQ
This document deals with gnuplot version 4.4 which is the latest official release as of March 2010.
Its version is $Revision: 1.40 $, dated $Date: 2010/03/14 06:59:57 $.
Contents
0 Meta – Questions 3
0.1 Where do I get this document? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
0.2 Where do I send comments about this document? . . . . . . . . . . . . . . . . . . . . . . . . 3
1 General Information 3
1.1 What is gnuplot? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2 How did it come about and why is it called gnuplot? . . . . . . . . . . . . . . . . . . . . . . 3
1.3 What does gnuplot offer? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.4 Is gnuplot suitable for scripting? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.5 Can I run gnuplot on my computer? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.6 Legalities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.7 Does gnuplot have anything to do with the FSF and the GNU project? . . . . . . . . . . . . . 4
1.8 Where do I get further information? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2 Setting it up 4
2.1 What is the current version of gnuplot? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.2 Where can I get gnuplot? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.3 Where can I get current development version of gnuplot? . . . . . . . . . . . . . . . . . . . . 5
2.4 How do I get gnuplot to compile on my system? . . . . . . . . . . . . . . . . . . . . . . . . 5
2.5 What documentation is there, and how do I get it? . . . . . . . . . . . . . . . . . . . . . . . . 5
2.6 Worked examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.7 How do I modify gnuplot, and apply ’patches’? . . . . . . . . . . . . . . . . . . . . . . . . . 6
1
4 Wanted features 11
4.1 What’s new in gnuplot 4.2, 4.4 etc? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
4.2 Does gnuplot support a driver for <graphics format>? . . . . . . . . . . . . . . . . . . . . . . 11
4.3 Does gnuplot have hidden line removal? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4.4 Does gnuplot support bar-charts/histograms/boxes? . . . . . . . . . . . . . . . . . . . . . . . 12
4.5 Does gnuplot support pie charts? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4.6 Does gnuplot quarterly time charts? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4.7 Can I put multiple pages on one page? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4.8 Does gnuplot support multiple y-axes on a single plot? . . . . . . . . . . . . . . . . . . . . . 12
4.9 Can I put both commands and data into a single file? . . . . . . . . . . . . . . . . . . . . . . 12
4.10 Can I put Greek letters and super/subscripts into my labels? . . . . . . . . . . . . . . . . . . . 12
4.11 How do I include accented characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
4.12 Can I do 1:1 scaling of axes? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
4.13 Can I put different text sizes into my plots? . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
4.14 How do I skip data points? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
4.15 How do I plot every nth point? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
4.16 How do I plot a vertical line? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
4.17 How do I plot data files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
4.18 How do I replot multiplot drawing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
5 Miscellaneous 14
5.1 I’ve found a bug, what do I do? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
5.2 Can I use gnuplot routines for my own programs? . . . . . . . . . . . . . . . . . . . . . . . . 14
5.3 What extensions have people made to gnuplot? Where can I get them? . . . . . . . . . . . . . 14
5.4 I need an integration, fft, iir-filter,...! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
5.5 Can I do heavy-duty data processing with gnuplot? or What is beyond gnuplot? . . . . . . . 15
5.6 Mouse in my interactive terminal does not work . . . . . . . . . . . . . . . . . . . . . . . . . 15
5.7 How to use hotkeys in my interactive terminals . . . . . . . . . . . . . . . . . . . . . . . . . 15
5.8 I have ported gnuplot to another system, or patched it. What do I do? . . . . . . . . . . . . . 16
5.9 I want to help in developing the next version of gnuplot. What can I do? . . . . . . . . . . . . 16
5.10 Open questions for inclusion into the FAQ? . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
7 Common problems 18
7.1 Help! None of my fonts work. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
7.2 Gnuplot is not plotting any points under X11! How come? . . . . . . . . . . . . . . . . . . . 19
7.3 Why does gnuplot ignore my very small numbers? . . . . . . . . . . . . . . . . . . . . . . . 19
7.4 Gnuplot is not plotting on the screen when run from command line via ’gnuplot filename.gp’ 19
7.5 My formulas (like 1/3) are giving me nonsense results! What’s going on? . . . . . . . . . . . 19
7.6 My output files are incomplete! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
7.7 When using the LATEX–terminal, there is an error during the LATEX–run! . . . . . . . . . . . . 20
7.8 I can’t find the demos and example files at the URLs in the documentation! . . . . . . . . . . 20
2
7.9 Calling gnuplot in a pipe or with a gnuplot-script doesn’t produce a plot! . . . . . . . . . . . 20
8 Credits 20
0 Meta – Questions
0.1 Where do I get this document?
The newest version of this document is on the web at www.gnuplot.info/faq/.
This document was/is posted sometimes to the newsgroups comp.graphics.apps.gnuplot.
1 General Information
1.1 What is gnuplot?
gnuplot is a command-driven interactive function plotting program. It can be used to plot functions and data
points in both two- and three-dimensional plots in many different formats. It is designed primarily for the visual
display of scientific data. gnuplot is copyrighted, but freely distributable; you don’t have to pay for it.
I was taking a differential equation class and Colin was taking Electromagnetics, we both thought
it’d be helpful to visualize the mathematics behind them. We were both working as sys admin for
an EE VLSI lab, so we had the graphics terminals and the time to do some coding. The posting
was better received than we expected, and prompted us to add some, albeit lame, support for file
data.
Any reference to GNUplot is incorrect. The real name of the program is "gnuplot". You see people
use "Gnuplot" quite a bit because many of us have an aversion to starting a sentence with a lower
case letter, even in the case of proper nouns and titles. gnuplot is not related to the GNU project or
the FSF in any but the most peripheral sense. Our software was designed completely independently
and the name "gnuplot" was actually a compromise. I wanted to call it "llamaplot" and Colin
wanted to call it "nplot." We agreed that "newplot" was acceptable but, we then discovered that
there was an absolutely ghastly pascal program of that name that the Computer Science Dept.
occasionally used. I decided that "gnuplot" would make a nice pun and after a fashion Colin
agreed.
• Plotting three-dimensional data points and surfaces in many different styles (contour plot, mesh)
3
• Support for a large number of operating systems, graphics file formats and output devices
1.6 Legalities
Gnuplot is freeware authored by a collection of volunteers, who cannot make any legal statement about the
compliance or non-compliance of gnuplot or its uses. There is also no warranty whatsoever. Use at your own
risk.
Citing from the README of a mathematical subroutine package by R. Freund:
For all intent and purpose, any description of what the codes are doing should be construed as
being a note of what we thought the codes did on our machine on a particular Tuesday of last year.
If you’re really lucky, they might do the same for you someday. Then again, do you really feel
*that* lucky?
1.7 Does gnuplot have anything to do with the FSF and the GNU project?
Gnuplot is neither written nor maintained by the FSF. It is not covered by the General Public License, either.
It used to be distributed by the FSF, however, due to licensing issues it is no longer.
Gnuplot is freeware in the sense that you don’t have to pay for it. However it is not freeware in the sense
that you would be allowed to distribute a modified version of your gnuplot freely. Please read and accept the
Copyright file in your distribution.
2 Setting it up
2.1 What is the current version of gnuplot?
The current released version of gnuplot is 4.4 (March 2010). The current patchlevel is 4.4.0 (March 2010).
4
2.2 Where can I get gnuplot?
The best place to start is www.gnuplot.info. From there you find various pointers to other sites, including
the project development site on SourceForge sourceforge.net/projects/gnuplot.
The source distribution ("gnuplot-4.4.0.tar.gz" or a similar name) is available from the official distribution
site sourceforge.net/projects/gnuplot.
Older versions of the gnuplot distribution are mirrored at the Comprehensive TeX Archive Network (CTAN)
in the graphics/gnuplot directory. See
• www.ctan.org/.
• For Unix, use ./configure (or ./configure --prefix=$HOME/usr for an installation for
a single user), make and finally make install or make install-strip, the latter for smaller
executables without debugging information. If you want to make a RPM package, then replace the lat-
est step by checkinstall or checkinstall make install-strip, supposing the package
checkinstall on your machine.
• For DOS, if you are using bash and DJGPP, you can just run djconfig.sh.
• For other platforms, copy the relevant makefile (e.g. makefile.os2 for OS/2, or makefile.mgw
or makefile.cyg for Windows) from config/ to src/, optionally update options in the makefile’s
header, then change directory to src and run make.
5
• a tutorial on using gnuplot with LATEX
The documentation is built during installation if you have LATEX installed on your system, look in the
directories docs and tutorial. make pdf in the docs subdirectory will make a gnuplot.pdf hypertext
file ready for browsing or printing.
Online gnuplot documentation is available at gnuplot.sourceforge.net/documentation.html.
6
gnuplot> set output # set output back to default
gnuplot> set terminal x11 # ditto for terminal type
gnuplot> ! lp -ops sin.ps # print PS File (site dependent)
request id is lprint-3433 (standard input)
lp: printed file sin.ps on fg20.rz.uni-karlsruhe.de (5068 Byte)
!
gnuplot>
Using the platform-independent way of restoring terminal by set term push/pop commands, do it by
gnuplot> set terminal postscript eps color lw 15 "Helvetica" 20
gnuplot> set out ’a.eps’
gnuplot> replot
gnuplot> set term pop
The command set term pop without a previous corresponding set term push switches the terminal
back to the startup terminal, e.g. x11, pm or win.
In MS Windows you can click in the upper left corner of the graph window and print directly from there.
• X11 toolkits: You can use the terminal type fig and use the xfig drawing program to edit the plot after-
wards. You can obtain the xfig program from its web site www.xfig.org. More information about the
text-format used for fig can be found in the fig-package.
7
You may use the tgif terminal, which creates output suitable for reading within tgif (bourbon.cs.
umd.edu:8001/tgif/), an interactive 2-D drawing tool under X11.
• You may use the svg terminal (scalable vector graphics), which can be further edited by a svg edi-
tor, e.g. Inkscape (www.inkscape.org), Sketch (sketch.sourceforge.net) or Dia (www.
lysator.liu.se/~alla/dia), or loaded into OpenOffice.org with an on-fly conversion into OO.o
Draw primitives.
• PostScript or PDF output can be edited directly by tools such as Adobe Illustrator or Acrobat, or can be
converted to a variety of other editable vector formats by the pstoedit package. Pstoedit is available at
www.pstoedit.net.
• The DXF format is the AutoCAD’s format, editable by several other applications.
• Bitmapped graphics (e.g. png, jpeg, pbm) can be edited using tools such as ImageMagick or Gimp. In
general, you should use a vector graphics program to post-process vector graphic formats, and a pixel-
based editing program to post-process pixel graphics.
3.5 How do I change symbol size, line thickness and the like?
Gnuplot offers a variety of commands to set line and point properties, including color, thickness, point shape,
etc. The command test will display a test page for the currently selected terminal type showing the available
pre-defined combinations of color, size, shape, etc. The set style command can be used to define additional
combinations.
The trick is to draw the single contour line z=0 of the surface z=f(x,y), and store the resulting contour curve to
a gnuplot datafile.
8
3.8 How to fill an area between two curves
A plot with filled area between two given curves requires a parametric plot with filledcurves closed.
The example below demonstrates this for two curves f(x) and g(x) with a tricky "folded" parameter t:
set parametric
f(x)=cos(x)
g(x)=sin(x)
xmax=pi/4
set xrange [0:xmax]
set trange [0:2*xmax]
path(t) = ( t<= xmax ? f(t) : g(2*xmax-t) )
fold(t) = (t <=xmax ? t : 2*xmax - t)
plot fold(t),path(t) with filledcurves closed
Note that the above code fills area between the two curves, not area satisfying inequality g(x)<f(x). If
you want the latter, you should use the ternary operator in path(t) to return an undefined value (0/0) if the
inequality is not satisfied.
See the documentation for help parametric, help filledcurves, and help ternary.
Then, either preprocess your data file by command awk -f addblanks.awk <a.dat or plot the datafile
under a unixish platform by gnuplot> splot "<awk -f addblanks.awk a.dat".
9
3.12 How to draw black contour plot, and contours with labels
Well, it is very simple even though it is hard to discover: unset clabel.
set contour both; set cntr levels 100
unset clabel
unset surface
splot x*y with line lt -1
pause -1
splot x*y with line palette
Another solution requires to write contours into a temporary file using the table terminal:
set contour base; set cntrparam levels 15; unset surface; set view map
splot x*x+y*y; pause -1
set table ’contour.dat’
replot
unset table
Now, for drawing it in 2D, do
reset
plot ’contour.dat’ with line -1
and for contours in 3D do
reset
# Change single blank lines to double blank lines
!awk "NF<2{printf\"\n\"}{print}" <contour.dat >contour1.dat
splot ’contour1.dat’ with line -1
See also the following question "How to overlay contour plot over pm3d map/surface".
Labelling contours by their z-value can be achieved by a suitable script generating automatically the appro-
priate set label commands; you can find one at gnuplot scripts page gnuplot.sourceforge.net/
scripts/index.html#tricks-here.
10
The last command deletes the two temporary files.
# triangle 1
x0 y0 z0 <c0>
x1 y1 z1 <c1>
x2 y2 z2 <c2>
x2 y2 z2 <c2>
# triangle 2
x y z
...
Notice the positioning single and double blank line. <c> is an optional color.
Then plot it by (either of splot’s):
set pm3d
set style data pm3d
splot ’facets.dat’
splot ’facets_with_color.dat’ using 1:2:3:4
Note that you avoid surface lines by set style data pm3d or splot ... with pm3d.
In the above example, pm3d displays triangles as independent surfaces. They are plotted one surface after
another, as found in the data file. Parts overlapping in 2D projection are overdrawn.
Gnuplot is not 3D modeling program. Its hidden routines apply for points and lines, but not for faces.
Without handling the data as a collection of faces, there would be no surface anything could be hidden behind.
The ’hidden3d’ algorithm works by using the input data in two ways: first, to set up a collection of triangles
(made from a mesh of quadrangles) that form the surface, second as a collection of edges. It then goes through
all those edges, checking what parts of them are not hidden behind any faces, and draws those.
Consequently, gnuplot won’t draw your surface or 3D object as a virtual reality. It works OK for set
pm3d map but for true 3D you would be probably more happy writing a convertor of your facets into a VRML
file.
3.15 Palette for printing my color map on color as well as black&white printer?
I think it is this one, for example: set palette rgbformulae -25,-24,-32. Can somebody prove
this?
4 Wanted features
4.1 What’s new in gnuplot 4.2, 4.4 etc?
Too many things to be named here. Please refer to the NEWS file in the source distribution, or the "New features"
section in the gnuplot documentation.
11
4.3 Does gnuplot have hidden line removal?
Yes.
4.9 Can I put both commands and data into a single file?
This is possible by the new plot "-" possibility. The plot "-" command allows to read the data to be
plot from standard input or the current batch job.
12
4.11 How do I include accented characters
To obtain accented characters like ü or n̂ in your labels you should use 8bit character codes together with the
appropriate encoding option. See the following example:
Consequently, you can type labels in Czech, French, Hungarian, Russian... by means of an appropriate
set encoding. However, you cannot mix two encodings in one file (e.g. accents for west and east latin
encodings).
A more general solution is to use UTF-8 encoded fonts, and type the UTF-8 characters directly into gnuplot.
This works for many terminal types but not, unfortunately, PostScript. Update: Version 4.4 contains contains
more complete support for UTF-8, including PostScript.
1 2
2 3
3 ?
4 5
See also set missing. See also set datafile commentschars for specifying comment char-
acters in data files.
• set arrow .... .... nohead where you have to compute explicitly the start and the end of the
arrow.
13
4.18 How do I replot multiplot drawing
You cannot directly: gnuplot supports replot command, not remultiplot. You have to write the complete
sequence of commands since set multiplot till unset multiplot into a script file. Then you can
load the script into gnuplot as many times as you need for replotting the drawing to different terminals or
output files.
5 Miscellaneous
5.1 I’ve found a bug, what do I do?
First, try to see whether it actually is a bug, or whether it is a feature which may be turned off by some obscure
set–command.
Next, see whether you have an old version of gnuplot; if you do, chances are the bug has been fixed in a
newer release.
Fixes for bugs reported since the release of the current version are held in the patches directory at gnuplot
distribution sites. Before submitting a bug report, please check whether the bug in question has already been
fixed.
If, after checking these things, you still are convinced that there is a bug, proceed as follows. If you have a
fairly general sort of bug report, posting to comp.graphics.apps.gnuplot is probably the way to go. If
you have investigated a problem in detail, especially if you have a context or unified diff that fixes the problem,
please e-email a report to [email protected].
The bug-gnuplot list is for reporting and collecting bug fixes, the comp.graphics.apps.gnuplot
newsgroup will be more help for finding work arounds or actually solving gnuplot related problems. If you
do send in a bug report, be sure and include the version of gnuplot (including patchlevel) as shown by the
command show version long, terminal driver, operating system, an exact description of the bug and
input which can reproduce the bug. Failure to indicate these details can render a solution to your problem
almost impossible. Also, any context diffs should be referenced against the latest official version of gnuplot if
at all possible.
5.3 What extensions have people made to gnuplot? Where can I get them?
Many extensions or patches are available on the "Patches" page of the gnuplot development site sourceforge.
net/tracker/?group_id=2055&atid=302055. The current development version will generally in-
clude some of these being debugged for inclusion in a later official release of gnuplot.
Older extensions, which may or may not work with the current version, are available from ftp.ucc.ie
in /pub/gnuplot/contrib/.
Some extensions available:
14
• Gnuplot.py: A python package to create graphs from within python. More information at gnuplot-
py.sourceforge.net.
5.5 Can I do heavy-duty data processing with gnuplot? or What is beyond gnuplot?
gnuplot alone is not suited very well for this. One thing you might try is fudgit, an interactive multi-
purpose fitting program written by Martin-D. Lacasse ([email protected]). It can use
gnuplot as its graphics back end and is available from ftp.physics.mcgill.ca in /pub/Fudgit/
fudgit_2.33.tar.Z and from the main Linux server, tsx-11.mit.edu and its numerous mirrors around the
world as /pub/linux/sources/usr.bin/fudgit-2.33.tar.z. Versions are available for AIX,
Data General, HP-UX, IRIX 4, Linux, NeXT, Sun3, Sun4, Ultrix, OS/2 and MS-DOS. The MS-DOS version is
available on simtel20 mirrors (simtel20 itself has closed down) in the "math" subdirectory as fudg_231.zip.
Michael Courtney has written a program called lsqrft, which uses the Levenberg-Marquardt - algorithm
for fitting data to a function. It is available from hobbes.nmsu.edu in /pub/os2/apps/analysis/
lsqrft15.zip; sources, which should compile on Unix, and executables for MS-DOS and OS/2 are avail-
able. There is an interface to the OS/2 presentation manager.
You might also want to look at the applications developed by the Software Tools Group (STG) at the Na-
tional Center for Supercomputing Applications. Ftp to ftp.ncsa.uiuc.edu and get the file README.BROCHURE
for more information.
You can also try pgperl, an integration of the PGPLOT plotting package with Perl 5. Information can
be found at www.ast.cam.ac.uk/AAO/local/www/kgb/pgperl, the source is available from ftp.
ast.cam.ac.uk in /pub/kgb/pgperl/ or linux.nrao.edu in /pub/packages/pgperl/.
Another possibility is Octave. To quote from its README: Octave is a high-level language, primarily
intended for numerical computations. Octave is licensed under GPL, and in principle, it is a free Matlab
clone. It provides a convenient command line interface for solving linear and nonlinear problems numerically.
The latest released version of Octave is always available from www.octave.org. By the way, octave uses
gnuplot as its plotting engine, so you get a data-processing program on top of gnuplot.
Finally, there is scilab at www-rocq.inria.fr/scilab/ doing about the same as matlab. It is free
but copyrighted software.
15
5.8 I have ported gnuplot to another system, or patched it. What do I do?
If your patch is small, mail it to [email protected], with a thorough description
of what the patch is supposed to do, which version of gnuplot it is relative to, etc. Well, please do it always
with respect to the current development version of gnuplot (see ’cvs’ above).
Nowadays, the preferred way of submitting, commenting and upgrading patches are via ’Patches’ section
on sourceforge.net/tracker/?group_id=2055&atid=302055. You may want to send a note to
[email protected] for more lively discussion.
5.9 I want to help in developing the next version of gnuplot. What can I do?
Join the gnuplot beta test mailing list by sending a mail containing the line subscribe gnuplot-beta
in the body (not the subject) of the mail to [email protected].
You can also use gnuplot’s ability to ignore mathematically undefined expressions: the expression 1/0 is
silently ignored, thus a construction like
The plot command is very powerful and is able to do some arithmetic on datafiles. See help plot.
The above filtering works seamlessly under Unixes and OS/2. It can work under MS Windows as well,
but that is for experienced users: (A) When gnuplot has been compiled by cygwin with the unixish way of
./configure; make with X11 terminal instead of the ’windows’ terminal. You have to run this under an
X-server. This procedure is out of knowledge for usual users, but powerful for others. (B) Compile gnuplot
yourself by makefile.mgw or makefile.cyg and set PIPES=1 therein. The drawback is that each
wgnuplot.exe will be accompanied by a boring shell box.
16
6.3 How do I make it easier to use gnuplot with LATEX?
There is a set of LATEX macros and shell scripts that are meant to make your life easier when using gnuplot with
LATEX. This package can be found on ftp.dartmouth.edu in pub/gnuplot/latex.shar, by David
Kotz. For example, the program "plotskel" can turn a gnuplot-output file plot.tex into a skeleton file skel.tex,
that has the same size as the original plot but contains no graph. With the right macros, the skeleton can be used
for preliminary LATEX passes, reserving the full graph for later passes, saving tremendous amounts of time.
6.6 How do I plot a function f(x,y) that is bounded by other functions in the x-y plane?
An example:
17
encoding), but I haven’t found a way to scale and position the pieces correctly. One more possibility would be
{/=14 @^{/Symbol=10 -}{/=14 h}}.
The reduced Planck’s constant can be set very easily by using the AMS-LaTeX PostScript fonts which
are available from www.ams.org/tex/amsfonts.html (also included in many LaTeX distributions).
Gnuplot (confer the help about fontpath) and the PostScript interpreter (usually Ghostscript) have to
know where the file msbm10.pfb (or msbm10.pfa) resides. Use {/MSBM10 \175} to produce
\hslash which is a "h" superimposed by a sloped bar. The standard \hbar (horizontal bar) has the octal
code 176. Please note that h-bar exists only as an italic type.
7 Common problems
7.1 Help! None of my fonts work.
Gnuplot does not do font handling by itself; it must necessarily leave that to the individual device support
libraries. Unfortunately, this means that different terminal types need different help in finding fonts. Here are
some quick hints. For more detailed information please see the gnuplot documentation for the specific terminal
type you are having problems with.
png/jpeg/gif These terminal types use the libgd support library, which searches for fonts in the directories given
in the environmental variable GDFONTPATH. Once you get libgd fontpaths sorted out, you will probably
want to set a default font for gnuplot. For example: setenv GNUPLOT_DEFAULT_GDFONT verdana
pdf The libpdf support library should have come with an associated font configuration file, usually installed as
/usr/local/share/pdflib.upr. The environmental variable PDFLIBRESOURCE should point to this file.
post PostScript font names are not resolved until the document is printed. Gnuplot does not know what fonts
are available to your printer, so it will accept any font name you give it. However, it is possible to bundle
a font with the gnuplot output; please see the instructions given by gnuplot’s internal command “help set
term post fontfile”.
x11 The x11 terminal uses the normal x11 font server mechanism. The only tricky bit is that in order to use
multi-byte fonts you must explicitly say so:
win Right-click in the control window, then select "Choose font" from the pull-down menu.
wxt On linux systems, the wxt terminal can find fonts indexed by the fontconfig utility.
18
7.2 Gnuplot is not plotting any points under X11! How come?
On VMS, you need to make several symbols:
Then run gnuplot from your command line, and use set term x11.
If you run gnuplot on Unix systems, be sure that the newest gnuplot_x11 is the first in your search path.
Command which gnuplot_x11 will help you.
7.4 Gnuplot is not plotting on the screen when run from command line via ’gnuplot filename.gp’
Obviously, it draws (unless there is an error in the script file), but the plot dissappears immediately when the
script is completed.
Solution 1: Put a pause -1 after the plot command in the file, or at the file end.
Solution 2: Use command gnuplot filename.gp - (yes, dash is the last parameter) to stay in the
interactive regime when the script completes.
Solution 3A: On an X-Window System system, you can also use the -persist option, the X11 window
is then not closed. Close the X11 window by typing "q" when the focus is on it.
Solution 3B: On M$ Windows, you can also use either -persist or /noend.
Solution 4: For OS/2 PM terminal, use set term pm persist or set term pm server. For
X11 terminal, use set term x11 persist.
7.5 My formulas (like 1/3) are giving me nonsense results! What’s going on?
Gnuplot does integer, and not floating point, arithmetic on integer expressions. For example, the expression 1/3
evaluates to zero. If you want floating point expressions, supply trailing dots for your floating point numbers.
Example:
19
7.6 My output files are incomplete!
You may need to flush the output with a closing set output. Some output formats (postscript, pdf, latex,
svg, ...) can include several pages of plots in a single output file. For these output modes, gnuplot leaves the
file open after each plot so that you can add additional plots to it. The file is not completed and made available
to external applications until you explicitly close it (set output or unset output), or select a different
terminal type (set term) or exit gnuplot. Output formats that contain only a single ’page’ (png, emf, ...)
should not suffer from this problem.
7.7 When using the LATEX–terminal, there is an error during the LATEX–run!
The LATEX2e-core no longer includes the commands "\Diamond" and "\Box"; they are included in the latexsym
package. Other symbols are taken from the amssymb package. Both of these are part of the base distribution and
thus part of any LaTeX implementation. Please remember to include these packages in your LaTeX document.
7.8 I can’t find the demos and example files at the URLs in the documentation!
The examples have been removed from the NASA site mentioned in older documentation. You can find demos
from the current version at gnuplot.sourceforge.net/demo. Examples from the development version
are at gnuplot.sourceforge.net/demo_cvs.
#!/usr/local/bin/perl -w
open (GP, "|/usr/local/bin/gnuplot -persist") or die "no gnuplot";
# force buffer to flush after each write
use FileHandle;
GP->autoflush(1);
print GP,"set term x11;plot ’/tmp/data.dat’ with lines\n";
close GP
Gnuplot closes its plot window on exit. The close GP command is executed, and the plot window is
closed even before you have a chance to look at it.
There are three solutions to this: first, use the pause -1 command in gnuplot before closing the pipe.
Second, close the pipe only if you are sure that you don’t need gnuplot and its plot window anymore. Last, you
can use the command line option -persist: this option leaves the X-Window System plot window open.
8 Credits
Gnuplot 3.7’s main contributors are (in alphabetical order) Hans-Bernhard Broeker, John Campbell, Robert
Cunningham, David Denholm, Gershon Elber, Roger Fearick, Carsten Grammes, Lucas Hart, Lars Hecking,
Thomas Koenig, David Kotz, Ed Kubaitis, Russell Lang, Alexander Lehmann, Alexander Mai, Carsten Steger,
Tom Tkacik, Jos Van der Woude, James R. Van Zandt, and Alex Woo. Additional substantial contributors
to version 4.0 include Ethan Merritt, Petr Mikulík and Johannes Zellner. Version 4.2 and 4.4 releases were
coordinated by Ethan Merritt.
This list was initially compiled by John Fletcher with contributions from Russell Lang, John Campbell,
David Kotz, Rob Cunningham, Daniel Lewart and Alex Woo. Reworked by Thomas Koenig from a draft by
Alex Woo, with corrections and additions from Alex Woo, John Campbell, Russell Lang, David Kotz and many
corrections from Daniel Lewart. Again reworked for gnuplot 3.7 by Alexander Mai and Juergen v.Hagen with
corrections by Lars Hecking, Hans-Bernhard Broecker and other people. Revised for gnuplot 4.0 release by
Petr Mikulík and Ethan Merritt. Revised for gnuplot 4.2 release by Petr Mikulík and Ethan Merritt. Revised
for gnuplot 4.4 release by Ethan Merritt.
20