简体   繁体   English

带表面图和点的Gnuplot

[英]Gnuplot with surface plot and points

I tried to do it like suggested in other posts. 我尝试按照其他帖子中的建议进行操作。 But the points were not printed. 但是这些点没有打印出来。 Where is my mistake: 我的错误在哪里:

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

Thanks for Help 感谢帮助

I assume your issue is the datafile separator . 我认为您的问题是datafile separator
If you look at the point_data.dat file, I'm sure it will list your points in columns but not separated by ; 如果您查看point_data.dat文件,我确定它会在列中列出您的点,但不要用;隔开; . Thus, when you attempt to plot both the point_data.dat and the field.csv (which I assume is separated by ; as well), the points will most likely not be plotted because gnuplot cannot interpret the point_data.dat -file (which uses the default separator of " " ). 因此,当您尝试绘制point_data.datfield.csv (我也假定以;分隔)时,由于gnuplot无法解释point_data.dat -file(使用默认的分隔符" " )。
There are two ways to overcome this: 有两种方法可以解决此问题:

  1. Do not use set datafile separator . 不要使用set datafile separator Instead, use awk to remove the ; 而是使用awk删除; while plotting: 在绘制时:

     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" 

    A few things to notice: 注意事项:

    • inside the awk -command, do not forgot to use backslashes with the quotation marks: \\" or else it will mess up the command (and result in an error). awk -command中,请不要忘记使用带引号的反斜杠\\" ,否则它将使命令混乱(并导致错误)。
    • consider unsing not to suppress a legend entry or use a defined title (eg title "points" ), otherwise the whole awk -command will be printed as title. 请考虑not取消显示图例条目或使用定义的标题(例如title "points" ),否则整个awk -command将被打印为标题。
  2. You can use the multiplot -command (and skip the set table ): 您可以使用multiplot -command(并跳过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 

    A few things to notice: 注意事项:

    • use not to print without legend, or else they will overlap. not在没有图例的情况下进行打印,否则它们会重叠。 If you need a legend, you cannot use multiplot like this, because they will overlap. 如果需要图例,则不能使用像这样的multiplot ,因为它们会重叠。
    • set the xrange , yrange and zrange before you plot, or else the axis ranges might not agree. 在绘制之前设置xrangeyrangezrange ,否则轴范围可能yrange (Be sure to replace xmin etc with the actual values from your data range). (确保将xmin等替换为数据范围内的实际值)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM