views:

281

answers:

4

Using gnuplot 4.2, is it possible to obtain the value of a specific column/row and use that value somehow?

For example, let's say my datafile contains the following

#1  2
7  13
5  11
23 17
53 12

For a simple plot where column 1 is the x axis and column 2 is the y axis I would:-

plot 'datafile' using 1:2

What I'm trying to do is to normalize the all data in column 2 by the first element in that column (13). Is there a way to do this in gnuplot itself (i.e., without resorting to a scripting language or something to preprocess the data first)?

Cheers

+1  A: 
plot 'datafile' using 1:($2/13)

You can get help from the interactive gnuplot environment (when you call it without arguments):

help plot using

There is also documentation in html or pdf format at the official gnuplot homepage:

http://www.gnuplot.info/documentation.html

edit: I do not think that there is a way to access specific data "cells" in gnuplot. It is no spreadsheet application. That said, siag (Scheme In A Grid) is a spreadsheet application that uses gnuplot, so you might be able to use it as a wrapper which gives you the power of a complete functional language (I have not tried this, though).

Svante
A: 

ad a new column full of 13, then use:

plot 'datafile' using 1:($2/$3)

A: 

No, it's not possible.

fuad
A: 

If your base value (e.g. 13) is in the first row of your data set, you should be able to do what you want using the CVS version of gnuplot.

Have a look at the running averages demo. Along those lines, you could write a custom function that stores the base value in a custom variable when called for the first time, and returns that variable on subsequent calls.

(Since that demo is listed for the CVS version only, I assume the required functionality is not available in the current release version.)

sapporo