Wednesday, 15 May 2013

data visualization - Plot all columns in a file using gnuplot without specifying number of columns -


I have a large number of data that I want to plot using gnuplot. In the files text column, as many columns I wanted to use Gnulplot to plot all the columns in any file, without identifying the number of columns to be plotted or the number of total columns in the file Without identifying, since the total number of columns varies, the files I have to have are such a way that I can use it gnuplot?

You can go about it differently, some more and some less elegant.

Make the following file as data as an example:

  1 2 3 2 5 5 5 3 1 3 4 5 2 5 5 5 6 4 2  

There are 3 columns in it, but you want to write a normal script without any particular number of assumptions. The way I had to go about this, send it to awk to get the number of columns in your file in the gnuplot script by system () call:

Have to use. [I = 1: N] "data" u 0: iwl title "column" .i
N = system ("awk 'NR == 1 {print NF}' 'data)

Enter image details here

Say you ' T wants to use the system () and know that the number of columns will always be less than a certain maximum, for example 10:

  for the plot [I = 1:10] "data" u 0: iwl title "column" .i  

Then the Gnulplet will complain about the non-existent data but still the column 1 to 3 will be the same.


No comments:

Post a Comment