gnuplot documentation
gnuplot documentation
gnuplot documentation
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
36 19 <strong>gnuplot</strong> STRING 4.3 CONSTANTS AND STRING VARIABLES<br />
for information about the requisite file structure for 3D data values; and set contour (p. 94) and set<br />
cntrparam (p. 92) for information about contours.<br />
In splot, control over the scales and labels of the axes are the same as with plot, except that commands<br />
and options controlling the x2 and y2 axes have no effect whereas of course those controlling the z axis<br />
do take effect.<br />
18 Start-up<br />
When <strong>gnuplot</strong> is run, it looks for an initialization file to load. This file is called .<strong>gnuplot</strong> on Unix and<br />
AmigaOS systems, and GNUPLOT.INI on other systems. If this file is not found in the current directory,<br />
the program will look for it in the HOME directory (under AmigaOS, Atari(single)TOS, MS-DOS,<br />
Windows and OS/2, the environment variable GNUPLOT should contain the name of this directory;<br />
on Windows NT, it will use USERPROFILE if GNUPLOT isn’t defined). Note: if NOCWDRC is<br />
defined during the installation, <strong>gnuplot</strong> will not read from the current directory.<br />
If the initialization file is found, <strong>gnuplot</strong> executes the commands in it. These may be any legal <strong>gnuplot</strong><br />
commands, but typically they are limited to setting the terminal and defining frequently-used functions<br />
or variables.<br />
19 String constants and string variables<br />
In addition to string constants, most <strong>gnuplot</strong> commands also accept a string variable, a string expression,<br />
or a function that returns a string. For example, the following four methods of creating a plot all result<br />
in the same plot title:<br />
four = "4"<br />
graph4 = "Title for plot #4"<br />
graph(n) = sprintf("Title for plot #%d",n)<br />
plot ’data.4’ title "Title for plot #4"<br />
plot ’data.4’ title graph4<br />
plot ’data.4’ title "Title for plot #".four<br />
plot ’data.4’ title graph(4)<br />
Since integers are promoted to strings when operated on by the string concatenation operator, the<br />
following method also works:<br />
N = 4<br />
plot ’data.’.N title "Title for plot #".N<br />
In general, elements on the command line will only be evaluated as possible string variables if they are<br />
not otherwise recognizable as part of the normal <strong>gnuplot</strong> syntax. So the following sequence of commands<br />
is legal, although probably should be avoided so as not to cause confusion:<br />
plot = "my_datafile.dat"<br />
title = "My Title"<br />
plot plot title title<br />
There are three binary operators that require string operands: the string concatenation operator ".",<br />
the string equality operator "eq" and the string inequality operator "ne". The following example will<br />
print TRUE.<br />
if ("A"."B" eq "AB") print "TRUE"<br />
See also the two string formatting functions gprintf (p. 101) and sprintf (p. 27).<br />
Substrings can be specified by appending a range specifier to any string, string variable, or string-valued<br />
function. The range specifier has the form [begin:end], where begin is the index of the first character of<br />
the substring and end is the index of the last character of the substring. The first character has index<br />
1. The begin or end fields may be empty, or contain ’*’, to indicate the true start or end of the original<br />
string. E.g. str[:] and str[*:*] both describe the full string str.