Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xmgrace: plot function of data

Tags:

xmgrace

How can I plot a function of data with xmgrace?

Let's say I have a 3-columns file and I want to plot the sum of 2nd and 3rd column as a function of the 1st. With gnuplot, I can just do

p "file.dat" u 1:($2+$3)

How can I do the same thing with xmgrace?

like image 595
valerio Avatar asked Apr 16 '26 06:04

valerio


2 Answers

awk '{print $1, ($2 + $3)}' file.dat | xmgrace -pipe &

Example: Plot data for y = x^2 + 4

Contents of file.dat:

0 0 4
1 1 4
2 4 4
3 9 4
4 16 4
5 25 4
6 36 4

Output (after modifying styles):

Plot of y = x^2 + 4

like image 140
feedMe Avatar answered Apr 17 '26 22:04

feedMe


A pure grace solution would be to create a batch file (say myplot.batch) that reads

READ BLOCK "file.dat"
BLOCK xy "1:2" 
BLOCK xy "1:3" 
s0.y=s0.y-s1.y 
KILL s1      

And execute using

xmgrace -batch myplot.batch
like image 28
h k Avatar answered Apr 17 '26 23:04

h k