Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
pmi432 / LR02 / Books / gnuplot 4.6 manual.pdf
Скачиваний:
55
Добавлен:
18.03.2015
Размер:
2.22 Mб
Скачать

gnuplot 4.6

37

"KP_Space", "KP_Tab", "KP_Enter", "KP_F1", "KP_F2", "KP_F3", "KP_F4", "KP_Home", "KP_Left", "KP_Up", "KP_Right", "KP_Down", "KP_PageUp", "KP_PageDown", "KP_End", "KP_Begin", "KP_Insert", "KP_Delete", "KP_Equal", "KP_Multiply", "KP_Add", "KP_Separator", "KP_Subtract", "KP_Decimal", "KP_Divide",

"KP_1" - "KP_9", "F1" - "F12"

The following are window events rather than actual keys

"Close"

See also help for mouse (p. 126).

Bind space

If gnuplot was built with con guration option {enable-raise-console, then typing <space> in the plot window raises gnuplot's command window. This hotkey can be changed to ctrl-space by starting gnuplot as 'gnuplot -ctrlq', or by setting the XResource 'gnuplot*ctrlq'. See x11 command-line-options (p. 228).

Mouse variables

When mousing is active, clicking in the active window will set several user variables that can be accessed from the gnuplot command line. The coordinates of the mouse at the time of the click are stored in MOUSE X MOUSE Y MOUSE X2 and MOUSE Y2. The mouse button clicked, and any meta-keys active at that time, are stored in MOUSE BUTTON MOUSE SHIFT MOUSE ALT and MOUSE CTRL. These variables are set to unde ned at the start of every plot, and only become de ned in the event of a mouse click in the active plot window. To determine from a script if the mouse has been clicked in the active plot window, it is su cient to test for any one of these variables being de ned.

plot 'something' pause mouse

if (defined(MOUSE_BUTTON)) call 'something_else'; \ else print "No mouse click."

It is also possible to track keystrokes in the plot window using the mousing code.

plot 'something' pause mouse keypress

print "Keystroke ", MOUSE_KEY, " at ", MOUSE_X, " ", MOUSE_Y

When pause mouse keypress is terminated by a keypress, then MOUSE KEY will contain the ascii character value of the key that was pressed. MOUSE CHAR will contain the character itself as a string variable. If the pause command is terminated abnormally (e.g. by ctrl-C or by externally closing the plot window) then MOUSE KEY will equal -1.

Note that after a zoom by mouse, you can read the new ranges as GPVAL X MIN, GPVAL X MAX, GPVAL Y MIN, and GPVAL Y MAX, see gnuplot-de ned variables (p. 30).

Plotting

There are three gnuplot commands which actually create a plot: plot, splot and replot. plot generates 2D plots, splot generates 3D plots (actually 2D projections, of course), and replot appends its arguments to the previous plot or splot and executes the modi ed command.

Much of the general information about plotting can be found in the discussion of plot; information speci c to 3D can be found in the splot section.

38

gnuplot 4.6

plot operates in either rectangular or polar coordinates { see set polar (p. 142) for details of the latter. splot operates only in rectangular coordinates, but the set mapping command allows for a few other coordinate systems to be treated. In addition, the using option allows both plot and splot to treat almost any coordinate system you'd care to de ne.

plot also lets you use each of the four borders { x (bottom), x2 (top), y (left) and y2 (right) { as an independent axis. The axes option lets you choose which pair of axes a given function or data set is plotted against. A full complement of set commands exists to give you complete control over the scales and labelling of each axis. Some commands have the name of an axis built into their names, such as set xlabel. Other commands have one or more axis names as options, such as set logscale xy. Commands and options controlling the z axis have no e ect on 2D graphs.

splot can plot surfaces and contours in addition to points and/or lines. See set isosamples (p. 117) for information about de ning the grid for a 3D function. See splot data le (p. 168) for information about the requisite le structure for 3D data values, set contour (p. 105) and set cntrparam (p. 102) for information about contours.

In splot, control over the scales and labels of the axes are the same as with plot, except that commands and options controlling the x2 and y2 axes have no e ect whereas of course those controlling the z axis do take e ect.

Start-up (initialization)

When gnuplot is run, it rst looks for a system-wide initialization le named gnuplotrc. The location of this le is determined when the program is built and is reported by show loadpath. The program then looks in the user's HOME directory for a le called .gnuplot on Unix-like systems or GNUPLOT.INI on other systems. (Windows and OS/2 will look for it in the directory named in the environment variable GNUPLOT; Windows will use USERPROFILE if GNUPLOT is not de ned). Note: The program can be con gured to look rst in the current directory, but this is not recommended because it is bad security practice.

String constants and string variables

In addition to string constants, most gnuplot commands also accept a string variable, a string expression, or a function that returns a string. For example, the following four methods of creating a plot all result in the same plot title:

four = "4"

graph4 = "Title for plot #4"

graph(n) = sprintf("Title for plot #%d",n)

plot 'data.4' title "Title for plot #4" plot 'data.4' title graph4

plot 'data.4' title "Title for plot #".four plot 'data.4' title graph(4)

Since integers are promoted to strings when operated on by the string concatenation operator, the following method also works:

N = 4

plot 'data.'.N title "Title for plot #".N

In general, elements on the command line will only be evaluated as possible string variables if they are not otherwise recognizable as part of the normal gnuplot syntax. So the following sequence of commands is legal, although probably should be avoided so as not to cause confusion:

plot = "my_datafile.dat" title = "My Title"

plot plot title title

Соседние файлы в папке Books