Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I plot certain columns using xmgrace in the terminal?

I want to write a bash script to automate the plotting of data, using a plotting tool called xmgrace, but I want to be able to select which columns are plotted.

Say in my data file I have 3 columns, with the x and y data in the 1st and 3rd columns. How do I plot x against y when the data is formatted this way?

I tried xmgrace -bxy [1:3] data but that didn't work, it said No block data read and treated the second column as the y values.

like image 328
Eddy Avatar asked Jan 14 '11 18:01

Eddy


People also ask

How do you plot a function in xmgrace?

select the line style for the lines connecting the points in the set. select the line width for the lines. the color to use when drawing lines. select the type of fill, none, as polygon, to y=0.0, x=0.0, x=graph Xmin, x=graph Xmax, y=graph Ymin, y=graph Ymax.

How do you plot a graph in xmgrace?

If you click on the Plot icon at the top of the xmgrace window, and then select Axis Properties, you will get a menu which allows you to control the range of the data shown (the values in the “Start” and “Stop” boxes). The very top box allows you to choose whether to work with the X- or Y- axis.


2 Answers

The correct syntax for this kind of problem is

xmgrace -block file -bxy 1:3 

This will

  1. Read the file as a block file
  2. Plot the 3rd column against the 1st column.
like image 191
Daniel Avatar answered Oct 22 '22 17:10

Daniel


Another flexible way of accomplishing the same thing is to use awk or cut:

awk '{print $1,$3}' data | xmgrace -
cut -f1,3 data | xmgrace -
like image 4
mstringer Avatar answered Oct 22 '22 18:10

mstringer