Gnuplot与表面图和点

时间:2013-07-26 12:51:50

标签: 3d gnuplot points geometry-surface

我尝试像其他帖子中建议的那样做。但这些要点没有打印出来。我的错误在哪里:

set decimalsign locale
set datafile separator ";"

set table 'point_data.dat'
    unset dgrid3d
    splot './points.csv' u 1:2:3
unset table

#set pm3d implicit at s
#set pm3d interpolate 1,1 flush begin noftriangles hidden3d 100 corners2color mean
set dgrid3d 50,50,50

set output 'field.pdf'

splot './point_data.dat' u 1:2:3 w points pt 7, \
      './field.csv' u 2:1:3 with lines lt 5 lc rgb "#000000"

set output
exit

感谢您的帮助

1 个答案:

答案 0 :(得分:1)

我认为您的问题是datafile separator 如果您查看point_data.dat文件,我确定它会在列中列出您的点,但不会被;分隔。因此,当您尝试绘制point_data.datfield.csv(我假设也由;分隔)时,这些点很可能不会被绘制,因为gnuplot无法解释point_data.dat - 文件(使用默认分隔符" ") 有两种方法可以解决这个问题:

  1. 请勿使用set datafile separator。相反,在绘图时使用awk删除;

    set decimalsign locale
    set table 'point_data.dat'
    unset dgrid3d
    
    splot "< awk 'BEGIN {FS=\";\"} {print $1, $2, $3}' points.csv" u 1:2:3
    
    unset table
    set dgrid3d 50,50,50
    
    splot "point_data.dat" u 1:2:3 w points pt 7, \
          "< awk 'BEGIN {FS=\";\"} {print $1, $2, $3}' field.csv" u 2:1:3 with lines lt 5 lc rgb "#000000"
    

    需要注意的一些事项:

    • awk - 命令中,不要忘记使用带引号的反斜杠:\"否则会弄乱命令(并导致错误)。
    • 考虑使用not来取消图例条目或使用已定义的标题(例如title "points"),否则整个awk - 命令将打印为标题。
  2. 您可以使用multiplot - 命令(并跳过set table):

    set datafile separator ";"
    
    set xrange [xmin:xmax]
    set yrange [ymin:ymax]
    set zrange [zmin:zmax]
    
    set multiplot
    splot "points.csv" u 1:2:3 w points pt 7 not
    set dgrid3d 50,50,50
    splot "field.csv" u 2:1:3 with lines lt 5 lc rgb "#000000" not
    unset dgrid3d
    unset multiplot
    

    需要注意的一些事项:

    • 使用not打印没有图例,否则它们会重叠。如果您需要图例,则不能像这样使用multiplot,因为它们会重叠。
    • 在您绘制之前设置xrangeyrangezrange,否则轴范围可能不一致。 (请务必使用数据范围中的实际值替换xmin等。)