Gnuplot - 绘制2D等高线图上的数据点

时间:2018-06-04 15:32:46

标签: gnuplot heatmap contour

我想将一些数据点(M_Coord_Plain.txt)绘制到2D轮廓投影上(由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

结果图只是轮廓2D投影,但没有任何点,没有错误。

1 个答案:

答案 0 :(得分:0)

最后它起作用了,但是必须进行以下更改:

  1. 在点数据文件(M_Coord_Plain.txt)中,每行之间都应包含一个空格,因为splot命令需要这种格式。
  2. 删除未设置表面命令,并用 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