How do I create a 3d phase-space plot in gnuplot?
gnuplot
Solution
To plot the 3d phase space use the following script, which works like the running average example from the gnuplot page:
reset
back4 = back3 = back2 = back1 = 0
shift(x) = (back4 = back3, back3 = back2, back2 = back1, back1 = x)
samples(x) = $0 < 3 ? NaN : x
set ticslevel 0
# the labels are only for orientation when checking the test data
set xlabel 'xlabel'
set ylabel 'ylabel'
splot 'randomdata.dat' using (shift($1), samples(back4-back3)):(samples(back3-back2)):(samples(back2-back1))
Gnuplot must hold four data values, which are stored in `back1` to `back4`. For every new value, the stored values are shifted with `shift`. `samples` takes care that the first three values are not used, but only stored (`NaN` creates an invalid data point).
To test it, use this file `randomdata.dat`:
21
15
10
6
3
1
0
This plots four data points at (6,5,4), (5,4,3), (4,3,2), and (3,2,1).
If you have a binary data file with e.g. 16bit numbers, use
splot 'binaryfile' binary format="%ushort" using (shift($1), samples(back4-back3)):(samples(back3-back2)):(samples(back2-back1))
If you need to change the datasize, invoke `gnuplot` and type `show datafile binary datasizes` to see which formats are supported.
Problem
See this article Enclosed, but not Encrypted. I have some binary data. I want to perform the gnuplots shown in that article, but using my data. For a three-dimensional phase-space plot, the sequence a, b, c, d, e, f, etc. can be used as space coordinates (a-b, b-c, c-d), (b-c, c-d, d-e), (c-d, d-e, e-f), etc. Patterns in the plot created reveal recurring relations between subsequent sequences. In this phase plot, 50,000 16-bit random numbers would produce an unstructured cloud of dots. I want to do exactly the same kind of thing. I have a binary file (about 10 MB) and I'd like to run it through gnuplot to create the nice gnuplot graphs. What do I type into gnuplot to make that happen? Doing a Google search for "phase space plot" and gnuplot doesn't return much. I don't know if that's because the article is a translation from German. I don't think I've found relevant answers in stack exchange sites.