Top: Table of contents
Up: Table of contents chapter 8
Next: 8.11 scatter data -> grid data
Previous: 8.9 contour

8.10 Random number

gnuplot 利用一简单的乱数产生器产生一组乱数,并绘于 2d 平面或 3d 立体空间中。由参数 sample 决定产生多少点 (若在 3d 中,参数 isosample 亦有影响),在图27 中 2d 之中是 set sample 1000,因此产生 1000 点。 而在 3d 之中 set sample 50,产生 50 * 20 = 1000 点。(因 isosamples 为 20,以 20 条线画出图形,故为 20 倍。) 此实际点数可将图形装置设定为 table 后,而得到数值的表示方法。

seed = 1317
seed = rand(seed)
set nokey
set xrange [0: 1]
set yrange [0: 1]
set title "lattice test for random numbers"
set xlabel "rand(n) ->"
set ylabel "rand(n + 1) ->"
set zlabel "rand(n + 2) ->"
set format x "%3.2f"
set format y "%3.2f"
set tics
set sample 1000
set function style dots
set parametric
plot rand(1), rand(1)
seed = 1317
seed = rand(seed)
set nokey
set xrange [0: 1]
set yrange [0: 1]
set zrange [0: 1]
set title "lattice test for random numbers"
set xlabel "rand(n) ->"
set ylabel "rand(n + 1) ->"
set zlabel "rand(n + 2) ->"
set format x "%3.2f"
set format y "%3.2f"
set format z "%3.2f"
set tics
set function style dots
set parametric
pause 0 "3d plot ahead, one moment please ..."
set sample 50
splot rand(1), rand(1), rand(1)

图 26: Example : random number


Top: Table of contents Next: 8.11 scatter data -> grid data