Question

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

Was it helpful?

Solution

I assume your issue is the datafile separator.
If you look at the point_data.datfile, I'm sure it will list your points in columns but not separated by ;. 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 " ").
There are two ways to overcome this:

  1. Do not use set datafile separator. Instead, use awk to remove the ; 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).
    • consider unsing not to suppress a legend entry or use a defined title (e.g. title "points"), otherwise the whole awk-command will be printed as title.
  2. You can use the multiplot-command (and skip the 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. If you need a legend, you cannot use multiplot like this, because they will overlap.
    • set the xrange, yrange and zrange before you plot, or else the axis ranges might not agree. (Be sure to replace xminetc with the actual values from your data range).
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top