📄 faq.txt
字号:
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 http://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 http://www-rocq.inria.fr/scilab/ doing about
the same as matlab. It is free but copyrighted software.
5.6 Mouse in my interactive terminal does not work
If your mouse is not working, try to hit 'm' in the interactive terminal
to switch mousing on/off. See below for the list of supported interactive
terminals.
If it still does not run, then either gnuplot has not been configured or
compiled with mouse support, or you have not properly installed it, or
running an older version of gnuplot (check your PATH).
If your gnuplot is running as the plotting engine of Octave under X11,
then please put gset mouse into your $HOME/.octaverc. According to
gnuplot's help x11, gnuplot under x11 running through a pipe needs set
mouse to be executed before launching the x11 plot window.
5.7 How to use hotkeys in my interactive terminals
There are several hotkeys available in interactive terminals. Currently
the following interactive terminals support hotkeys and mousing: OS/2
Presentation Manager, X11, Windows, and GGI. Hit 'h' in the terminal to
get list of hotkeys. See help new or the What is New in 4.0 section in the
docs for a brief guide over mousing and hotkeys. Further, you may read
help mouse and help bind for more information.
5.8 I have ported gnuplot to another system, or patched it. What do I do?
If your patch is small, mail it to gnuplot-beta@lists.sourceforge.net,
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
http://www.sourceforge.net/projects/gnuplot/. You may want to send a note
to gnuplot-beta@lists.sourceforge.net 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
Majordomo@lists.sourceforge.net.
Also check with http://sourceforge.net/projects/gnuplot about latest
source for beta releases for development.
5.10 Open questions for inclusion into the FAQ?
gnuplot-beta@lists.sourceforge.net.
Please submit your questions (along with the answer) to
gnuplot-beta@lists.sourceforge.net.
6 Making life easier
6.1 How do I plot two functions in non-overlapping regions?
Use a parametric plot. An example:
gnuplot> set parametric
gnuplot> a=1
gnuplot> b=3
gnuplot> c=2
gnuplot> d=4
gnuplot> x1(t) = a+(b-a)*t
gnuplot> x2(t) = c+(d-c)*t
gnuplot> f1(x) = sin(x)
gnuplot> f2(x) = x**2/8
gnuplot> plot [t=0:1] x1(t),f1(x1(t)) title "f1", x2(t), f2(x2(t)) title "f2"
You can also use gnuplot's ability to ignore mathematically undefined
expressions: the expression 1/0 is silently ignored, thus a construction
like
gnuplot> set xran [-10:10]
gnuplot> plot (abs(x)>0.5?1/0: x**2)
plots a quadratic function only for |x| < 0.5.
6.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"
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.
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.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.
You can save the current terminal and restore it later without touching
the filesystem by set term push and set term pop, respectively.
6.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.
6.6 How do I plot a function f(x,y) that is bounded by other functions in the
x-y plane?
An example:
gnuplot> f(x,y) = x**2 + y **2
gnuplot> x(u) = 3*u
gnuplot> yu(x) = x**2
gnuplot> yl(x) = -x**2
gnuplot> set parametric
gnuplot> set cont
gnuplot> 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)
6.7 How do I turn off <feature> in a plot?
Most gnuplot features are controlled by a corresponding set/unset command.
If a feature is enabled by default, or by using set <feature>, then you
should be able to turn it by using set no<feature>. However, the prefered
syntax in version 4.0 is unset <feature>.
6.8 How do I call gnuplot from my own programs?
On unix-like systems, commands to gnuplot can be piped via stdin. Output
from gnuplot's print command can be read via a named pipe. On M$ Windows
platforms, due to the lacking standard input (stdin) in GUI programs, you
need to use the helper program pgnuplot which should be included in your
gnuplot for M$W distribution package. Reading gnuplot output may be
impossible.
6.9 What if I need h-bar (Planck's constant)?
There is no predefined variable like pi. However to put h-bar as a
character into the label, you must use the PostScript terminal. You can
play around with constructs like @{/=56 -} {/=24 h} or {/=8 @{/Symbol=24
-} _{/=14 h}} In the latter, the "-" (a long one in /Symbol) is
non-spacing and 24-pt. The 14-pt "h" is offset by an 8-pt space (which is
the space preceding the "_") but smaller, since it's written as a
subscript. But these don't look too much like the hbar we're used to,
since the bar is horizontal instead of sloped. I don't see a way to get
that. I tried using an accent (character 264 in iso-latin-1 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}}.
(This is a hint by Richard Crawford).
6.10 How do a produce blank output page?
Well, you probably don't want a blank page, but page with a just a title
(overprinting title in another graph in multiplot page):
reset; unset xtics; unset ytics
unset border; unset key
set title 'Title on an empty page'
plot [][0:1] 2
7 Common problems
7.1 Gnuplot is not plotting any points under X11! How come?
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 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.2 My isoline data generated by a Fortran program is not handled correctly.
What can I do?
Update to the newest gnuplot. Gnuplot 3.7 is able to read Fortran-style
files where a blank line can contain more than a linefeed.
7.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, type help set zero.
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:
gnuplot> print 1/3
0
gnuplot> print 1./3.
0.333333
This way of evaluating integer expressions is shared by both C and
Fortran.
7.6 Set output 'filename' isn't outputting everything it should!
You may need to flush the output with a closing set output.
7.7 When using the LATEX-terminal, there is an error during the LATEX-run!
Please upgrade to at least gnuplot 3.7. The LATEX2$\epsilon$-core no
longer includes the commands "$\backslash$Diamond" and "$\backslash$Box";
they are included in the latexsym package, which is part of the base
distribution and thus part of any LaTeX implementation. Please do not
forget to use this package.
7.8 The exit command does not work as documented!
This is an old bug and is fixed in newer releases.
7.9 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 currently find the version 3.7 examples at
http://www.gnuplot.vt.edu/gnuplot/gpdocs. Version 4.0 examples are at
http://gnuplot.sourceforge.net/demo.
7.10 Calling gnuplot in a pipe or with a gnuplot-script doesn't produce a plot!
You can call gnuplot by using a short Perl-script like the following:
#!/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 Mikulik and Johannes Zellner.
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 Mikulik and Ethan Merritt.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -