Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have gnuplot data file. I would like to plot it, but divide every value in the x-axis by n.

Can I do this from within gnuplot, or do I have to rewrite the data file?

share|improve this question
add comment

1 Answer

up vote 6 down vote accepted

Supposing that the x values are in the first column of the file 'test.dat' and the y values are in the second column of the same file, than you can operate on the values in the following way:

plot 'test.dat' using ($1/n):($2)

see the manual for more information and examples on the 'using' keyword.

Note that this will not change the values of your data file 'test.dat'. Instead, if you prefer to rewrite the data file, you can do it automatically through awk. For example:

awk '{print $1/n,$2}' test.dat > testnew.dat

will substitute the x values in the first column of test.dat with x/n and will generate a new file called testnew.dat.

share|improve this answer
1  
+1 in either case. –  ldigas Feb 13 '10 at 13:17
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.