i'm a new user of gnuplot. i would like to know how to make a 2-D contour
plot (e.x. flow velocities in a box, etc). how would i arrange the data?
thank you very much
kahar osman
Assuming you have a recent gnuplot (version 3.7.1), check out
help contour
for a description of the usual method, and
help splot datafile
for what your datafile should look like.
--
Hans-Bernhard Broeker (bro...@physik.rwth-aachen.de)
Even if all the snow were burnt, ashes would remain.
> i'm a new user of gnuplot. i would like to know how to make a 2-D contour
> plot (e.x. flow velocities in a box, etc). how would i arrange the data?
Good question from a beginner . . .
Contour plotting is a 3D operation in gnuplot -- a 2D contour plot is simply
a down-axis projection of a 3D plot. So you must use the "splot" command
instead of "plot".
The file structure must be a logical grid:
x00 y00 z00
x10 y10 z10
x20 y20 z20
. . .
N0 yN0 zN0
[blank line]
x01 y01 z01
x11 y11 z11
x21 y21 z21
. . .
xN1 yN1 zN1
[blank line]
x02 y02 z02
and so forth.
Then
set contours
splot 'file_name' with lines
is all that's necessary. There are options to control the contours in "set
cntrparam" and the viewing angle can be changed with "set view". See the
on-line "help" for details.
But there seems to be no convenient way to get a normal-looking 2D contour
plot -- a "splot", no matter how it's viewed, always seems to have one axis
or the other labelled strangely. Also a "splot" is scaled smaller than a
"plot" (so that all possible orientations will still fit on the page).
To get around both of these problems -- as well as get more control over
line types and the layout of the key -- you can write the contours to a file
and then "plot" them as data. To do this, use "set terminal table" and "set
output 'file_name' ". When you plot from 'file_name', you'll have to use a
filter in the "using" option to select the contour. For example, since the
contour is the "z" value and is in column 3, you can plot the "z=5" contour
with
plot 'file_name' using 1:($3==5? $2: 0/0) with lines
(Check out "help plot using" and "help ternary" for more details about
what's going on here.)
I hope this is enough to get you started
Dick Crawford, aka craw...@arete.com