Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.graphics.apps.gnuplot > #2772 > unrolled thread

Scatter plot from a binary data

Started bymaksym.petrenko@gmail.com
First post2015-02-20 11:55 -0800
Last post2015-02-20 11:55 -0800
Articles 1 — 1 participant

Back to article view | Back to comp.graphics.apps.gnuplot


Contents

  Scatter plot from a binary data maksym.petrenko@gmail.com - 2015-02-20 11:55 -0800

#2772 — Scatter plot from a binary data

Frommaksym.petrenko@gmail.com
Date2015-02-20 11:55 -0800
SubjectScatter plot from a binary data
Message-ID<5af7b56d-4f68-4876-b654-eaf7b8fdbcd6@googlegroups.com>
Hi guys, I'm trying to marry nco tools and gnuplot to produce a scatter plot of some fairly large data. A short version of the question is this. Given a binary file of 4 float numbers:

#X1#X2#Y1#Y2


I'd like to build a scatter plot that has points (x:X1,y:Y1), (x:X2,y:Y2). I tried several things, like this for example:


plot 'scatter00' binary record=(2):(2) format="%float" using 1:2 lc rgb 'blue' title '' 


However, all of them seem to produce a version of (x:X1,y:X2), (x:Y1,y:Y2). I wonder if there is a way to tell gnuplot the file contains ALL elements of X followed by ALL elements of Y, rather than pairs of Xn,Yn?



A long version of the question:

As an input, I have an .nc file with two FLOAT variables, x and y, of the same size - say 100,000,000 points each. Since gnuplot does not work with .nc files directly, I need to somehow serialize the file. My current approach is to dump each x and y to separate text files using ncks, each file essentially a column of float numbers, and then merge these files into a single two-column CSV-like file using Unix 'paste'. While dumping takes about a minute, merging takes about 2-3 minutes. Plotting takes about 5 seconds. Now, the reason I need to merge the two files is because gnuplot expects the input data to be in a form of records:

X1 Y1
X2 Y2
...
Xn Yn

In the same time, ncks can dump data only sequentially, either to separate files or to a single file: 
X1
X2
...
Xn
Y1
Y2
...
Yn

I then tried to dump to a binary file with an idea that gnuplot can read in the binary file as an array and manipulate it according to rows/columns. Again, ncks gives me something like this:

(#X1#X2...#Xn#Y1#Y2...#Yn)

Gnuplot, on the other hand, expects something like this:

(#X1#Y1#X2#Y2...)

When I try this command:

plot 'scatter00' binary record=(600000):(600000) format="%float" using 1:2 lc rgb 'blue' title '' 

I expect gnuplot to read in 600000 elements of X followed by 600000 elements of Y. However, what happens is gnuplot still reads X1,Y1,X2,Y2...X600000,Y600000. Is there a way to modify the command to read in the original data without reshuffling the bytes?

many thanks,
Maksym

[toc] | [standalone]


Back to top | Article view | comp.graphics.apps.gnuplot


csiph-web