![]() |
| Home > Photo, Video, Graphics > graphics > |
comp.graphics.apps.gnuplot FAQ (Frequent Answered Questions) |
Section 2 of 2 - Prev - Next
Q4.8: Can I put tic marks for x and y axes into 3d plots?
In version 3.5, you can; use the "with boxes" option.
Q4.9: Does gnuplot support a driver for ?
To see a list of the available graphic drivers for your
installation of gnuplot, type "set term".
Some graphics drivers are included in the normal distribution,
but are uncommented by default. If you want to use them, you'll
have to change ~gnuplot/term.h, and recompile.
Q4.10: Can I put different text sizes into my plots?
If you use PostScript output, you can use Dave Denholm's and
Matt Heffron's updated PostScript driver,
/sotona.phys.soton.ac.uk:/enhpost.trm (see also Q4.6 ).
Else, use 3.6.
Q4.11 How do I modify gnuplot, and apply 'patches'?
For this, you will need to recompile gnuplot.
Modifications people make are either done by replacing files,
such as terminal drivers, or by 'patching'. If a file is a
replacement, it will probably tell you in its README or in the
lines at the beginning.
To patch a file, you need Larry Wall's patch utility. On many
UNIX systems, it is already installed; do a man patch to check.
If it isn't, you'll have to get it; it can be found wherever
GNU software is archived.
Q4.12 How do I skip data points?
By specifying ? as a data value, as in
1 2
2 3
3 ?
4 5
Q4.13 How do I plot every nth point?
You can apply the patch point_skip from the contrib section
(see Q5.3 or, assuming you have awk installed on your
system, you can use the following line:
gnuplot> plot "< awk '{if(NR%5==0)print}' file.dat"
plots every 5th line, and
gnuplot> plot "< awk '$0 !~ /^#/ {if(NR%40==0)print $1, $4}' file.dat"
plots every 40th line while skipping commented lines.
Section 5: Miscellaneous
Q5.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 wether you have an old version of gnuplot; if you do,
chances are the bug has been fixed in a newer release.
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 diff that fixes the problem, please e-email a
report to bug-gnuplot@dartmouth.edu. 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), terminal driver,
operating system, an exact description of the bug and input
which can reproduce the bug. Also, any context diffs should be
referenced against the latest official version of gnuplot if at
all possible.
Q5.2: Can I use gnuplot routines for my own programs?
Yes. John Campbell has written
gplotlib, a version of gnuplot as C subroutines callable from a
C program. This is available as gplotlib.tar.Z on the machine
ftp.nau.edu in the directory /pub/gplotlib.tar.Z. This library
has been updated to be compatible with version 3.5.
Q5.3: What extensions have people made to gnuplot? Where can I get
them?
__Extensions are available from
ftp://ftp.dartmouth.edu/pub/gnuplot/contrib/ . It contains
the following files:
Point Skips
+ _Data Filtering_ Instead of just having two params
following the style param, there are now 4:
o 1: line_type
o 2: point_type
o 3: point_skip - gives the number of data samples per
plotted point
o 4: point_offs - gives the sample number on which to plot
the first point
Thus points are plotted only for the samples n satisfying n =
point_skip*i + point_offs for some non-negative integer i.
From:
pixar!sun!prony.Colorado.EDU!clarkmp@ucbvax.berkeley.edu
(Michael Clark)
+ _Point Skip with Awk_ With UNIX,
gnuplot> plot "< awk '{if(NR%5==0)print$0}' file.dat"
From: James Darrell McCauley, mccauley@ecn.purdue.edu
+ _New Xlib mods._ From: gregg hanna
(gregor@kafka.saic.com)
Vectors and Arrows
+ _Program to convert lines to vectors_ This program turns
line segments into line segments with a half-arrow at the
head: by uncommenting two lines below, the arrowhead will be
a triangle. optional arguments: size angle where size is a
fraction of each vector's magnitude and angle is in degrees
all data taken from standard input, and output to standard
output. typical invocation:
arrow 0.2 15 vector.heads
From: andrew@jarthur.claremont.edu (Andrew M. Ross)
+ _Vect2gp_, an awk script to make gnuplot command script
to draw a vector field map. From: hiro@ice3.ori.u-tokyo.ac.jp
(Yasu-Hiro YAMAZAKI)
+ _GNUPLOT to SIPP_ This is a "far from perfect" converter
that takes gnuplot table output and splits it in polygons.
Then it calls sipp to render it. You get sipp from
isy.liu.se:/pub/sipp or ask archie. From:
chammer@POST.uni-bielefeld.de (Carsten Hammer)
Histograms and Pie Charts
+ _Histogram C program_ The short C program below is a
filter that calculates a histogram from a sequence of numbers
and prints the output in such a format that Gnuplot can plot
the histogram by the command sequence
!histogram < datain > tmp;
plot "tmp" with impulses
From: mustafa@seas.smu.edu (Mustafa Kocaturk)
+ _HG_ is an automatic histogram generator. it reads a
column of data from an input file and emits a [log] histogram
ks does ks or chi^2 tests on a set of input arrays. you need
the "numerical recipes in C" library somewhere on your system
to link this one. I can not undertake to fix bugs or add
features, but I might do it if asked. From: Steve Cumming
stevec@geog.ubc.ca
+ _Piechart C program_ The short C program below formats
data for display as a piechart. From: mccauley@ecn.purdue.edu
(James Darrell McCauley)
Interprocess Communications
+ _Notes of Windows Hooks_ From: Maurice
Castro,maurice@bruce.cs.monash.edu.au
+ _Named Pipes Example _From:
dtaber@deathstar.risc.rockwell.com (Don Taber)
+ _PipeLib_ What the library does is set up to 20 programs
going (like gnuplot), then allows you to send to them as if
the program were typing on the command line. I've included a
brief set of docs after the source code, in latex format.
There is no facility to watch the output of a program. From:
ssclift@neumann.uwaterloo.ca (Simon Clift)
+ _Popen example from lsqrfit_ The following function
sends a command to gnuplot. Gnuplot will execute the command
just as if you typed it at the gnuplot command line. This
example is adapted from my least squares fitting program
which is located at ftp.cdrom.com in
pub/os2/2_x/unix/lsqrft14.zip. Complete source is included.
From: michael@krypton.mit.edu (Michael Courtney)
Multiple logical plots on a single page
+ _Gawk script for multiple encapsulated postscript on a
page_ It's slightly more flexible than mpage, because it
changes the aspect ratio of the plots; mpage according to the
documentation only allows 1, 2, 4, or 8 plots on a page. This
script works for unix with encapsulated postscript (eps)
output. It should work with gawk or nawk, although I've only
tested it with gawk. (Gawk is GNU's version of awk and is
available from prep.ai.mit.edu.) You just specify how many
rows and columns of plots you want and it does the rest. For
example, gnuplot_eps rows=3 cols=2 *.eps | lpr will print all
eps files in your current directory with 6 on a page. Also,
see the comments in the file. From:
holt@goethe.cns.caltech.edu (Gary Holt)
+ _Sed script for multiple encapsulated postscript on a
page_ You have MULTIPLE postscript files each containing a
single plot. From: wgchoe@scoupe.postech.ac.kr (Choe Won Gyu)
+ _Massive patch_ with add multiplotcapability to all
devices and a lot more. The reason it is offered in this form
is because the original multiplot.pat did not patch correctly
into gnuplot version 3.5. This mod also add borders options,
financial plots, multiple line titles and other asundry
items. Use at your own risk. Look at the top of makefile.r
for a more complete list of changes.
From: Alex Woo, woo@playfair.stanford.edu
lvs.zip
This contains miscellaneous, modifications, which include:
+ Label positioning using either plot or device-relative
coodinates
+ Portability to Irix-5.2 and Irix-5.3
+ The "thru" keyword has been extended to include "thrux" for
the X - Coordinate
+ Capability to read a ordinary Fortran-style unformatted file
+ A Perl script for better handling of eps
+ Modifications to docs/doc2info to generate "next", "prev",
and "up" data for each node.
+ Changes in the documentation to reflect the above.
Miscellaneous Mods
+ _Congp3d3_ is a preprocessor to draw contour plots on
irregular regions. From: mrb2@nrc.gov (Margaret Rose Byrne)
+ _Sockpipe_ is a socket based pipe needed for the
Stardent OS. From: Mike Hallesy, Stardent Computer Product
Support, hal@stardent.com
+ _Time Series_ is a patch to add multiline titles and
labels, time series x and y data and tic marks, and automatic
resizing of plots and much more. From: Hans Olav Eggestad,
olav@jordforsk.nlh.no
Other Operationing Systems
+ _MacIntosh Port of Version 3.2_ From: Noboru Yamamoto,
sun!kekvax.kek.jp!YAMAMOTO@pixar.com
+ _MacIntosh Port of Version 3.5_ From:
laval@londres.cma.fr (Philippe LAVAL)
+ _OS-9 Port of Version 3.2_
Q5.4: Can I do heavy - duty data processing with 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
(isaac@frodo.physics.mcgill.ca). 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 [132.206.9.13], and from the
main Linux server, tsx-11.mit.edu [18.172.1.2] 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.
Carsten Grammes has written a fitting program which goes
together with gnuplot; it is called gnufit and is available
from the official gnuplot sites, as the files gnufit12.info,
gnufit12.tar.gz (source) and gft12dos.zip (MS-DOS). It has been
merged into gnuplot 3.6.
Michael Courtney has written a program called lsqrft, which
uses the Levenberg - Marquardt - Algorithm for fitting data to
a function. It is avialiable from ftp.cdrom.com as
/pub/os2/2_x/unix/lsqrft13.zip; sources, which should compile
on Unix, and executables for MS-DOS and OS/2 2.x are included.
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 National Center for
Supercomputing Applications. Ftp to ftp.ncsa.uiuc.edu
[141.142.20.50] 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
http://www.ast.cam.ac.uk/~kgb/pgperl.html, the source is
available from ftp://ftp.ast.cam.ac.uk/pub/kgb/pgperl/ or
ftp://linux.nrao.edu/pub/packages/pgperl/.
Another possibility is Octave. To quote from its README: Octave
is a high-level language, primarily intended for numerical
computations. It provides a convenient command line interface
for solving linear and nonlinear problems numerically.
The latest released version of Octave is always available via
anonymous ftp from bevo.che.wisc.edu in the directory
/pub/octave.
Q5.5: I have ported gnuplot to another system, or patched it. What do
I do?
If your patch is small, mail it to bug-gnuplot@dartmouth.edu,
with a thorough description of what the patch is supposed to
do, which version of gnuplot it is relative to, etc. Also, you
can send notification of the patch to the FAQ maintainer, if
you want a mention. Please don't send the patch itself to me
:-)
If your modifications are extensive (such as a port to another
system), upload your modifications to
ftp://ftp.dartmouth.edu/pub/dropoff. Please drop a note to
David.Kotz@dartmouth.edu, the maintainer of the gnuplot
subdirectory there, plus a note to bug-gnuplot@dartmouth.edu.
Q5.6: I want to help in developing gnuplot 3.6. What can I do?
Join the gnuplot beta test mailing list by sending a mail
containing the line
subscribe info-gnuplot-beta
in the body (not the subject) of the mail to Majordomo@Dartmouth.EDU.
Section 6: Making life easier
Q6.1: How do I plot two functions in non - overlapping regions?
Use a parametric plot. An example:
set parametric
a=1
b=3
c=2
d=4
x1(t) = a+(b-a)*t
x2(t) = c+(d-c)*t
f1(x) = sin(x)
f2(x) = x**2/8
plot [t=0:1] x1(t),f1(x1(t)) title "f1", x2(t), f2(x2(t)) title "f2"
Q6.2: How do I run my data through a filter before plotting?
If your system supports the popen() function, as Unix does, you
should be able to run the output through another process, for
example a short awk program, such as
gnuplot> plot "< awk ' { print $1, $3/$2 } ' file.in"
Unfortunately, in 3.2, there is a rather short limitation on the
maximum argument length, so your command line may be truncated
(usually, this will mean that awk cannot find the filename).
Also, you may need to escape the $ - characters in your awk
programs.
As of version 3.4, gnuplot includes the thru - keyword for the
plot command for running data files through a gnuplot - defined
function.
You can also get divhack.patch from
sotona.phys.soton.ac.uk[152.78.192.42] via anonymous ftp. It
allows expressions of the kind
gnuplot> plot "datafile" using A:B:C
where A,B,C,... are now either a column number, as usual, or an
arbitrary expression enclosed in ()'s, and using $1,$2,etc to
access the data columns.
Q6.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 [129.170.16.54, soon
to be 129.170.8.11] 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.
Q6.4: How do I save and restore my settings?
Use the "save" and "load" commands for this; see "help save"
and "help load" for details.
Q6.5: How do I plot lines (not grids) using splot?
If the data in a data file for splot is arranged in such a way
that each one has the same number of data points (using blank
lines as delimiters, as usual), splot will plot the data with a
grid. If you want to plot just lines, use a different number of
data entries (you can do this by doubling the last data point,
for example). Don't forget to set parametric mode, of course.
Q6.6: How do I plot a function f(x,y) which is bounded by other
functions in the x-y plain?
An example:
f(x,y) = x**2 + y **2
x(u) = 3*u
yu(x) = x**2
yl(x) = -x**2
set parametric
set cont
splot [0:1] [0:1] u,yl(x(u))+(yu(x(u)) - yl(x(u)))*v,\
f(x(u), (yu(x(u)) - yl(x(u)))*v)
Q6.7: How do I get rid of ?
Usually, there is a set command to do this; do a
gnuplot> ?set no
for a short overview.
Q6.8: How do I call gnuplot from my own programs?
Here's code which works for a UNIX system, using (efficient)
named pipes.
#include
#include
#include
#include
#include
#include
#define PANIC(a) do { \
perror(a); \
if (temp_name) unlink(temp_name);\
exit(1);\
} while(0)
int main() {
FILE *command,*data;
char *temp_name = NULL;
double a,b;
int i;
if ((temp_name = tmpnam((char *) 0)) == 0) PANIC("tmpnam failed");
if(mkfifo(temp_name, S_IRUSR | S_IWUSR) != 0) PANIC("mkfifo failed");
command = popen("gnuplot","w");
fprintf(command,"plot \"%s\" with lines\n",temp_name); fflush(command);
data = fopen(temp_name,"w");
for (i=0; i<20; i++) {
a = i/10.0;
b = sin(a);
fprintf(data,"%f %f\n",a,b);
}
fclose(data);
fprintf(stderr,"press enter to continue..."); fflush(stderr);
getchar();
fprintf(command,"plot \"%s\" with lines\n",temp_name); fflush(command);
data = fopen(temp_name,"w");
for (i=0; i<20; i++) {
a = i/10.0;
b = cos(a);
fprintf(data,"%f %f\n",a,b);
}
fclose(data);
fprintf(stderr,"press enter to continue..."); fflush(stderr);
getchar();
pclose(command);
unlink(temp_name);
return 0;
}
Here's code for OS/2, again using named pipes; I'm unable to check
this out myself. This code is care of fearick@physci.uct.ac.za
(Roger Fearick).
#include
#define INCL_DOS
#define INCL_DOSPROCESS
#define INCL_DOSNMPIPES
#include
main()
{
HPIPE hpipe ;
FILE *hfile, *hgnu ;
/* create a named pipe. Use NP_WAIT so that DosConnect...
blocks until client (gnuplot) opens, and client reads
are blocked until data is available */
DosCreateNPipe( "\\pipe\\gtemp",
&hpipe,
NP_ACCESS_OUTBOUND,
NP_WAIT|NP_TYPE_BYTE|1,
256,
256,
-1 ) ;
/* use stream i/o */
hfile = fdopen( hpipe, "w" ) ;
/* start gnuplot; use unbuffered writes so we don't need to
flush buffer after a command */
hgnu = popen( "gnuplot", "w" ) ;
setvbuf( hgnu, NULL, _IONBF, 0 ) ;
/* plot a set of data */
fprintf( hgnu, "plot '/pipe/gtemp'\n" ) ; /* issue plot command */
DosConnectNPipe( hpipe ) ; /* wait until 'file' opened */
fprintf( hfile, "1 1\n" ) ; /* write data to 'file' */
fprintf( hfile, "2 2\n" ) ;
fprintf( hfile, "3 3\n" ) ;
fprintf( hfile, "4 4\n" ) ;
fflush( hfile ) ; /* flush buffer forces read */
DosSleep( 500 ) ; /* allow gnuplot to catch up */
DosDisConnectNPipe( hpipe ) ; /* disconnect this session */
fprintf( hgnu, "pause -1\n" ) ; /* admire plot */
/* plot another set of data */
fprintf( hgnu, "plot '/pipe/gtemp'\n" ) ;
DosConnectNPipe( hpipe ) ;
fprintf( hfile, "1 4\n" ) ;
fprintf( hfile, "2 3\n" ) ;
fprintf( hfile, "3 2\n" ) ;
fprintf( hfile, "4 1\n" ) ;
fflush( hfile ) ;
DosSleep( 500 ) ;
DosDisConnectNPipe( hpipe ) ;
fprintf( hgnu, "pause -1\n" ) ;
DosClose( hpipe ) ;
pclose( hgnu ) ;
}
; The above code works for gnuplot 3.5. In gnuplot 3.6, this can be
greatly simplified, since data can be fed 'inline, as in
plot '-' w l
1 1
2 3
3 4
e
Section 7: Known problems
Q7.1: Gnuplot is not plotting any points under X11! How come?
Very probably, you still are using an old version of
gnuplot_x11. Remove that, then do a full installation.
On VMS, you need to make several symbols:
$ gnuplot_x11 :== $disk:[directory]gnuplot_x11
$ gnuplot :== $disk:[directory]gnuplot.exe
$ def/job GNUPLOT$HELP disk:[directory]gnuplot.hlb
Then run gnuplot from your command line, and use
gnuplot> set term x11
Q7.2: My isoline data generated by a Fortran program is not handled
correctly. What can I do?
One known cause for this is the use of list-directed output (as
in WRITE(10,*) for generating blank lines. Fortran uses ASA
carriage control characters, and for list - directed output
this results in a space being output before the newline.
Gnuplot does not like this. The solution is to generate blank
lines using formatted output, as in WRITE(10,'()'). If you use
carriage return files in VMS Fortran, you may have to open the
file with OPEN(...,CARRIAGECONTROL='DTST') or convert it using
the DECUS utility ATTRIB.EXE:
VMS> ATTRIB/RATTRIB=IMPDTED FOR010.DAT
Q7.3: Why does gnuplot ignore my very small numbers?
Gnuplot treats all numbers less than 1e-08 as zero, by default.
Thus, if you are trying to plot a collection of very small
numbers, they may be plotted as zero. Worse, if you're plotting
on a log scale, they will be off scale. Or, if the whole set of
numbers is "zero", your range may be considered empty:
gnuplot> plot 'test1'
Warning: empty y range [4.047e-19:3e-11], adjusting to [-1:1]
gnuplot> set yrange [4e-19:3e-11]
gnuplot> plot 'test1'
^
y range is less than `zero`
The solution is to change gnuplot's idea of "zero":
gnuplot> set zero 1e-20
For more information,
gnuplot> help set zero
Q7.4: Gnuplot is plotting nothing when run via gnuplot !
What can I do?
Put a pause -1 after the plot command in the file.
Q7.5: My formulas 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:
gnuplot> print 1/3
0
gnuplot> print 1./3.
0.333333
This way of evaluating integer expressions is shared by both C and
Fortran.
Q7.6: My Linux gnuplot complains about a missing gnuplot_x11. What is
wrong?
The binary gnuplot distribution from sunsite.unc.edu and its
mirrors in Linux/apps/math/gplotbin.tgz is missing one
executable that is necessary to access the x11 terminal. Please
install gnuplot from another Linux distribution, e.g.
Slackware.
Q7.7: set output 'filename' isn't outputting everything it should!
You need to flush the output with a closing 'set output'.
Section 8: Credits
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; Axel Eble and Jutta Zimmermann helped with the
conversion to HTML.
Thomas Koenig, ig25@rz.uni-karlsruhe.de, 1994-03-28
--
Thomas Koenig, Thomas.Koenig@ciw.uni-karlsruhe.de, ig25@dkauni2.bitnet.
The joy of engineering is to find a straight line on a double
logarithmic diagram.
Section 2 of 2 - Prev - Next
| Back to category graphics - Use Smart Search |
| Home - Smart Search - About the project - Feedback |
© allanswers.org | Terms of use