【gnuplot】pm3d plotに等高線(contour)を重ね書きしてみる (original) (raw)

まずは以下のようなデータを用意する
めんどくさかったので awk コマンドを使って作成した ( 前記事参照 )

そのデータを使ってgnuplotで等高線 + pm3d mapのplotをしてみる

-------------

基本的には次のページを参考にした

Gnuplot tricks: Basic statistics with gnuplot

まず 前記事 のデータを
そのままpm3d mapでplotしてみると

set pm3d map
set xtics 1
set ytics 1
splot "hoge.txt"

でこんな感じになる

次に等高線のデータをtableコマンドを使って作成する

set contour base
set cntrparam level incremental 0, 20, 100
unset surface
set table "contour.dat"
splot "hoge.txt"
unset table

でできたデータをwith lineでplotしてみると

plot "contour.dat" w l lw 2 lc -1

これらを重ね書きしてみる。

set xrange [0:4]
set yrange [0:4]
set xtics 1
set ytics 1
#set isosample 250, 250
set table 'image.txt'
splot "hoge.txt"
unset table

set term png
set output "image.png"
set pm3d map
splot "image.txt"

reset
set contour base
set cntrparam level incremental 0, 20, 100
unset surface
set table 'contour.txt'
splot "hoge.txt"
unset table

set term png
set output "contour.png"
set xtics 1
set ytics 1
plot "contour.txt" w l lw 2 lc -1

reset
set term x11
set xtics 1
set ytics 1
set xrange [0:4]
set yrange [0:4]
unset key
set palette rgbformulae 33,13,10
set term png
set output "op_image.png"
p 'image.txt' with image, 'contour.txt' w l lt -1 lw 2

set term png
set output "op_image2.png"
set pm3d explicit map
splot "hoge.txt" with pm3d, "contour.txt" w l lw 2 lt -1

長いですが、そのまま書いておきます

op_image.pngとop_image2.pngを比較してみると・・・

■ op_image.png

■ op_image2.png

びみょーに違いますね・・・
自分は下の方がお好みなので、下で行くことにします

もし下で良いならば、最初のtableの段落は不要なのでかなり短くなります

参考にしていたページにはもう一つ、等高線に数字を付けるというスクリプトも載っていました