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


Groups > comp.graphics.apps.gnuplot > #524

Re: help with reformatting the data file to generate a heatmap gnu plot.

From James Waldby <not@valid.invalid>
Newsgroups comp.graphics.apps.gnuplot
Subject Re: help with reformatting the data file to generate a heatmap gnu plot.
Date 2011-08-07 16:51 +0000
Organization A noiseless patient Spider
Message-ID <j1mfrb$gi5$1@dont-email.me> (permalink)
References <b724981d-c7be-4741-9206-7aed714741f0@g5g2000prn.googlegroups.com>

Show all headers | View raw


On Tue, 02 Aug 2011 15:34:07 -0700, anky wrote:

> So i have file that looks like this:
> 
> 2011-06-21 17:44:46.530931	21258	23073	23953	24130	
[snip 114 numbers] 
> ...	45000	65535
> 
> this is 1 row of the file with 124 values. The next row will have a new
> timestamp and corresponding 124 values. i want to make a heatmap which
> plots them in 10*12 matrix which means, i just use the first 120 values.
> I want to do something like this
> http://gnuplot.sourceforge.net/demo_4.2/heatmaps.html ( 1st example) .
> In my case the 120 values correspond to color intensity it would show.
> The problem is i will read these values  from an external file and i
> need to reformat this in form of a matrix to generate a heatmap like the
> one shown in example.
> 
> This is my first time using gnuplots and i dont have much idea about it.
> Is there way that i can read these in as strings and then format them as
> a 10*12 matrix ??

You might need to reformat the data externally.  For example,

awk -vL=1 -vb=3 -ve=123 -vk=10 'NR==L {for(i=b;i<e;++i){ printf " %d",$i; if (((i-b)%k)==k-1) printf "\n" }}' data.file

will process only line 1.  It will discard the timestamp numbers, and 
print 12 lines like following:

 21258 23073 23953 24130 22604 21228 21724 22321 21683 20634
 20111 19894 20327 18160 20973 21218 20648 21302 21605 20884
[snip 8 lines]
 22299 22084 20928 20932 21194 18949 18723 21129 20183 20346
 20293 21103 22440 19436 22467 25005 24913 24279 25117 22610

To select which line is processed, change the number in "-vL=1" 
to desired line number.  To change number of numbers printed per
line, change the number in "-vk=10".  To store the output in a 
file, add (for example)  > data.out   after the name of the input
file, which is data.file in this example.

Here's an example of bash commands that will process lines 1 to 13
from input file 'data.file' and produce output data files 'out1' ...
'out13' :

 for m in {1..13}; do 
   awk -vL=$m -vb=3 -ve=123 -vk=10 'NR==L {for(i=b;i<e;++i){ \
       printf " %d",$i; if (((i-b)%k)==k-1) printf "\n" }}' \
   data.file > out$m; done

-- 
jiw

Back to comp.graphics.apps.gnuplot | Previous | NextPrevious in thread | Find similar


Thread

help with reformatting the data file to generate a heatmap gnu plot. anky <ankit.10arya@gmail.com> - 2011-08-02 15:34 -0700
  Re: help with reformatting the data file to generate a heatmap gnu plot. James Waldby <not@valid.invalid> - 2011-08-07 16:51 +0000

csiph-web