I just want to save some gnuplot-generated data to a data file with help of the 'set table' command. The data should be a vector and his length. The vector offset is calculated to any point of an input-file 'filed.dat'. Printing the vector-data to the file is no problem. I do it this way:
splot 'field.dat' using 1:2:3:(-$2):($3):($1):(sqrt(($1)**2+($2)**2+($3)**2)) with vectors;
The Output is for example something like that:
# x y z delta_x delta_y delta_z type
-2 -3 -4 3 -4 -2 i
-1 -3 -4 3 -4 -1 i
0 -3 -4 3 -4 0 i
1 -3 -4 3 -4 1 i
2 -3 -4 3 -4 2 i
But i want to add the calculated vector length to the output file. It should look like this:
# x y z delta_x delta_y delta_z length type
-2 -3 -4 3 -4 -2 5.39 i
-1 -3 -4 3 -4 -1 5.10 i
0 -3 -4 3 -4 0 5.00 i
1 -3 -4 3 -4 1 5.10 i
2 -3 -4 3 -4 2 5.39 i
Does anyone know how to do it with gnuplot?
This is not possible in gnuplot, because a maximum of six columns is written to the output file (for other plotting styles than vectors
its less).
However, you could pipe the table output through e.g. awk
to add this information:
set output '| awk ''{\
if (!match($1, "^#") && length()) {\
print $1, $2, $3, $4, $5, $6, sqrt($4**2 + $5**2 + $6**2), $7\
} else {\
print $0}\
}'' > field-out.dat'
set table
splot 'field.dat' using 1:2:3:(-$2):3:1 with vectors
unset table
You must use set output
in order to use the pipe, set table "| ..."
doesn't work.