Learning xvgr

Learning xvgr


Getting Started

Start xvgr by typing xvgr. If you have a data file with columns of data representing x and y values, read these into the plot by first clicking the right mouse button on the file menu. Next click the left mouse button on read block data item, select your data file name, then choose which columns you wish to be x and y. To see your plot, click the left mouse button on AS to auto-scale your plot.

Saving a Plot

There are 3 ways to save a plot:

Printing a Plot

Once you have your plot, select Print from the file menu. To save as a postscript file, select Print Options from the file menu, then choose write to file and enter a file name. After exiting xvgr use lpr filename to print your postscript plot.

Customizing a Plot

You can customize many aspects of your plot.

Multiple Plots

You can have 10 or more plots on a single page. First, select Graphs from the view menu. Then choose Arrange graphs and choose number of rows and columns. You will need to change the width and height of plots to fit all onto a single page. Packing will place multiple plots next to each other.

To read data into multiple plots, click mouse button on a plot, notice the graph number in upper left corner of screen changes. Read in data to that particular plot.

Running xvgr from a script

You can save time by loading parameter files and data files from a shell script. The following script invokes xvgr with a parameter file and loads the data files into multiple plots.

#!/bin/sh
# example xvgr file to read data into 6 graphs
# each datafile has 2 columns, for x and y values
# -device 2 sets output to portrait instead of landscape
# pack.6 is the parameter file

xvgr -device 2 -p pack.6 \
-graph 0 datafile0 \
-graph 1 datafile1 \
-graph 2 datafile2 \
-graph 3 datafile3 \
-graph 4 datafile4 \
-graph 5 datafile5

Create the above script using the vi editor, name it plot.1. Make it executable by typing chmod +x plot.1. Now run it by typing plot.1. (Note: the parameter file pack.6 must already exist).