I have a binary files that have binary format='%float32%float32%float32'
, having D3 points (using 1:2:3
). Originally logically points grouped by 3 to form triangles. I want to plot just legs of triangles as a lines using with lines
. In ASCII data file I can make so-called datablocks by adding an empty line between triples of lines, but in binary I can't. I want to break a chain of lines at every three points to form at least V-like parts of triangle contours.
Is there an option to make gnuplot
to treat a triples of points as separate datablocks?
Is there another option to splot
the data as (maybe) a solid triangles?
I'm still not sure whether I'm fully on the right track.
The following code writes your binary data into a table and makes groups of 3 datapoints for a triangle, inserting an empty line and then shifted by one for the next triangle.
So, So from the points p1=f1,f2,f3
; p2=f4,f5,f6
; p3=f7,f8,f9
; ... it creates the triangles p1p2p3p1 p2p3p4p2 p3p4p5p3
(space=empty line).
Certainly, not very (memory) efficient, but maybe this gets closer to your final goal.
Check help pm3d
and help hidden3d
, where you might get some additional information.
I very much hope that there is a better approach.
Code: (assuming the binary file 'myBinary.bin'
, not sure whether I decoded your ASCII string correctly)
# plot binary data
reset session
# put binary data into a datablock
set table $Data
plot 'myBinary.bin' u 1:2:3 binary format='%float32%float32%float32' skip=12 w table
unset table
# separate each triangle by an empty line
set print $Data2
do for [i=1:|$Data|-2] {
print $Data[i]
print $Data[i+1]
print $Data[i+2]
print $Data[i]
print "" # insert empty line
}
set print
set pm3d hidden3d
set view 40, 24
splot $Data2 u 1:2:3 w pm3d notitle
### end of code
Result:
Perfect solution. Thank you very much! There is a need in one another
print ""
to make two separate triangles instead of triangle strip. Really example data consists of header + 18 floats. Thank you. Didn't know aboutset table
.glad to hear. I hope somebody else will come up with a better solution.
strange... If I add a second empty line, nothing will be plotted.
This is because of
pm3d
.