Some people seem to think that xmgrace is somehow cool, maybe because it contains an “x” on its name. Y personally prefer gnuplot or mathplotlib, but I got recently some “.agr” files I had to edit, and I finally decided to write a python script called agr2gpt, which makes a simple conversion from xmgrace files to gnuplot script, and extracts the data to different files (one per curve).
This is just the first version, so it just handles basic 2D graphs with several curves.
Besides the x and y data for each curve (unlimited amount of curves), it also parses the “xlabel” the “ylabel” and the legend of each curve.
As in most of my scripts, the “-h” option will provide some extra information about the usage, but in this first version, there are only two options: “-f” for the file name, and “-pl” if you want the pylab window to pop up with the image.
The usage is just:
julen@pc:~/home/julen/./agr2gpt -f grace_file.agr (-pl)
This time is the first time I have used the “argparse” module instead of “sys.arg” for parsing the command line options, and it feels convenient so far.
I might be adding some new options some day, but this little script should be enough for converting any basic 2D graph.
The script can be downloaded in the following link: agr2gpt