merge for datablocks

Daniel Montezano <[email protected]>
Newsgroups gmane.comp.graphics.gnuplot.devel
Message-ID <[email protected]>
Hi,

I just read about the patch for a "merge" command 
(https://sourceforge.net/p/gnuplot/patches/615/) that would allow 
merging the results of two plot commands into a single datablock that 
could then be used for a subsequent plot that needed both results. I 
don't think this was added to gnuplot. I tried "merge" in my current 
gnuplot version (5.2.8) and I get an "invalid command" reply.

It sounds it would be useful for combining data from different 
datablocks or files.
My use case for this would be creating a plot of the percentage of 
points in each interval that have a specific values from another column.

For example, for a file called "datafile.txt", containing values between 
0 and 1 in COL1 and a binary label in COL2:
COL1 COL2
0.1    0
0.2    1
0.1    1
0.33    0
0.4    1
1.0    0
0.9    0
0.12    1
0.13    1
0.13    0
0.89    1
0.88    0
....

A "merge" command would help to plot the following curve:

- percentage of points having COL1 between [0.0, 0.1] and COL2==1
- percentage of points have COL1 in the range [0.1,0.2] and COL2==1
- percentage of points have COL1 in the range [0.2,0.3] and COL2==1
and so on.

Currently, I am able to achieve this with "table" and "smooth frequency":
--------------------------------------------------------------------------------
# define function for binning data
binwidth = 0.1
bin(val) = binwidth * floor(val/binwidth)

# save total counts in each bin
set table "fileA"
plot "datafile.txt" using (bin(column("COL1"))):(1.0) smooth frequency 
with points

# save counts in each bin with a specific label
set table "fileB"
plot "datafile.txt" using (bin(column("COL1"))):(column("COL2") > 0 ? 
1.0 : 0.0) smooth frequency with points
unset table

# plot the percentage of dots with label "1" in each bin of width 0.1
plot "< paste fileA fileB" using 1:($5/$2) with linespoints
--------------------------------------------------------------------------------


Clearly this could be achieved pre-processing the data externally, but 
it looks like that the proposed "merge" command for datablocks would be 
a useful tool here.
It would simplify this without the need for writing data to files and 
reading it back.


Thank you,

__________________________________
Daniel Montezano
Center for Computational Biology
University of Kansas
Lawrence, KS 66045


_______________________________________________
gnuplot-beta mailing list
[email protected]
Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-beta
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.