網上關于Gnuplot三維繪圖的介紹比較少,我在這裡做下自己學習記錄,詳細的代碼注釋就不想寫了,我自己是參考官方幫助文檔和在bookzz.org下載下傳的一本英文電子書學習的,不想翻譯了,有興趣的話可以自己查閱相關資料,很多詳細參數設定都能在幫助文檔找到,比如
show colornames
可以輸出顔色的名稱,對繪圖有很大幫助。其他的介紹在其他博文有很多介紹我就不說了,寫完這篇還要忙着複習考試。。。
1、Making a surface plot
reset
set isosamples 40
unset key
set hidden3d
set title "J_0(r^2)"
set xrange [-4:4]
set yrange [-4:4]
set ztics 1
splot besj0(x**2+y**2)
set view 29,53 #Done implicitly by mousing.
set term pngcairo mono enhanced
#set out 'bessel.png'
replot
結果如下:

2、Coloring the surface
pm3d是palette-mapped 3d,可以了解為調色闆,為surface潤色
reset
set isosamples 100
set samples 100
unset key
set title "J_0(r^2)"
set xrange [-4:4]
set yrange [-4:4]
set ztics 1
unset surface
set pm3d
splot besj0(x**2+y**2)
結果如下:
3、Making a contour plot
reset
f(x,y) = 3*(1-x)**2*exp(-x**2-(y+1)**2)-10*(x/5-x**3-y**5)*exp(-x**2-y**2)-1/3*exp(-(x+1)**2-y**2) #matlab的peaks函數
set cntrparam levels 10
set contour both
unset sur
set view map
set xrange [-4:4]
set yrange [-4:4]
set iso 100
set samp 100
set key rmargin
splot f(x,y)
結果如下:
4、Plotting a path in 3D
reset
set samp 100
set xtics .4
set ytics .4
set parametric
set urange [-pi:pi]
set ztics 1
splot cos(u),sin(3*u),cos(5*u) lw 2
結果如下:
5、Drawing parametric surfaces
5.1
reset
set param
set iso 50
set ztics .5
set xtics .4
set ytics .4
set hidden3d
set urange [-pi:pi]
set vrange [-pi:pi]
splot cos(u)*cos(v), sin(u)*sin(v), sin(u)
結果如下:
5.2
reset
set param
set iso 50
set ztics .5
set xtics .4
set ytics .4
set urange [-pi:pi]
set vrange [-pi:pi]
set pm3d depthorder
splot cos(u)*cos(v), sin(u)*sin(v), sin(u) with pm3d
結果如下: