How to plot .xvg files from GROMACS on Windows

GROMACS produces graphical output in the form of .xvg files. These are designed to be viewed with a classic UNIX/Linux plotting program called Grace. If you happen to be using Linux and you have Grace installed, it is very easy to plot the data with the command

xmgrace my_file.xvg


If you aren’t using Linux, plotting .xvg files is quite a bit more difficult. Gnuplot is the only free plotting program that I have found that can handle .xvg files. Gnuplot is available for Windows (there is a direct download link near the top of the download page), but I will caution you that Gnuplot is not easy to learn. It has a command-line interface, and there are no point-and-click options to do basic operations such as labeling the axes of the plot. If you are using Gnuplot, you can plot the contents of an .xvg file with the command:

plot "my_filename.xvg" u 1:2 w lines

If you are more comfortable with Microsoft Office, you can also plot the contents of .xvg files using Excel. Start Excel, choose File->Open, and select “All Files (*.*) in the lower right corner of the dialog.  Select a .xvg file and press Open.  The text import wizard should start.  Choose Fixed width, Enter 14 where it says, “Start import at row: “ and press Next. A screenshot is shown below.xvg_import_step1

 In the next window, remove one of the black vertical lines, and move the other one to Column 15 as shown below. Press Finish.

xvg_import_step2If your import was successful, your spreadsheet should look like this:

xvg_data_importedNow, highlight the first two columns and insert a scatter plot (with lines) as shown below:

xvg_Excel_plotAlthough I generally don’t recommend using Excel for making publication-quality plots, it can be useful if you don’t have better tools available.

2 thoughts on “How to plot .xvg files from GROMACS on Windows”

  1. Sigma plot. Import as text file from around line 26 with white space delimiter. You will need to change the file header from .xvg to .txt so it comes up on sigma plots file filters. Then you can plot pretty nice figure sigma plot.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.