Gnuplot - 在二维等高线图上绘制数据点

Gnuplot - Plot data points on 2D contour plot

我想绘制一些数据点 (M_Coord_Plain.txt) onto a 2D contour projection (which is made by data on Contours.txt)。

我在这些帖子中找到了类似的答案:How to mark some points on 2D heat map in gnuplot?, Overlaying points onto a pm3d map? ,但不幸的是,这些在我的情况下似乎不起作用。

首先我设置选项:

set pm3d explicit   
unset surface     # Switch off the surface    
set view map      # Set a bird eye (xy plane) view    
set contour       # Plot contour lines    
set key outside    
set cntrparam cubicspline   # smooth out the lines    
unset colorbox

然后我用 splot 命令绘图:

splot 'Contours.txt' using 1:2:3 notitle with pm3d,\
      'M_Coord_Plain.txt' with points nocontour using 1:2:(0) pt 7

结果图只是等高线二维投影,上面没有点,也没有错误。

终于成功了,但必须进行以下更改:

  1. 在点数据文件 (M_Coord_Plain.txt) 的每一行之间包含一个 space 因为 splot 命令需要这种格式。
  2. 删除unset surface命令并替换为set surface命令,因为数据点绘制在表面上。然而,由于零值的相应颜色(定义的第三列 :(0) )默认为深紫色,因此这些点看起来很模糊。
  3. 因此我们可以使用黑白调色板并定义范围广泛的颜色框范围,以便在零轮廓值和高轮廓值之间形成较大的对比。

所以绘制请求图的命令是:

set pm3d explicit
set surface
set view map  # Set a bird eye (xy plane) view
set contour  # Plot contour lines
set key outside
set cntrparam cubicspline  # Smooth out the lines
set cntrparam levels discrete 3.197,3.552  # Plot the selected contours
unset colorbox
set cbrange [0:7000]  # Set the color range of contour values.
set palette model RGB defined ( 0 'white', 1 'black' )
set style line 1 lc rgb '#4169E1' pt 7 ps 2
splot 'Contours.txt' using 1:2:3 with pm3d notitle,\
      'M_Coord_Plain.txt' using 1:2:(0) with points ls 1 notitle

结果图是 this