Skip to content

XVG Visualizer

Plot GROMACS .xvg output and other numeric tables column by column, with the axis titles and legends the file carries.

Drop an .xvg or data file here

GROMACS @ lines or a CSV header row label the plot; # comments are skipped and the numeric columns are plotted.

.xvg.csv.txt.dat
How-to guide

How to visualize your data

Drop a GROMACS .xvg (or any whitespace or CSV table of numbers) and plot any of its columns. The page reads the file's own labels, so the axes and legends come out labelled.

1

Load a file

Drag & drop or select a .xvg, .csv, .txt or .dat file, or press Load a sample to try a synthetic RMSD and radius-of-gyration trace. Everything is parsed in your browser.

2

Pick columns

Choose which column is the x axis, then tick any number of series to overlay. A series on a very different scale goes in a Lower panel under the others, sharing the x axis. Legends and axis titles come from the file's @ lines, or a CSV's header row, when present; GROMACS's sub- and superscripts and Greek letters are set as they print.

3

Smooth and style it

Draw a running mean over a noisy trace, with the data faded under it, and switch markers or a log y axis from the plot's header. The Style tab sets the size, fonts, labels, limits, ticks, colours, legend and grid of the saved figure; the preview is drawn at that size, as it will be saved.

4

Save it, or take the script

Save the figure as PDF, PNG or SVG. The Python script under the plot draws the same figure with matplotlib: it reads your file with numpy.loadtxt, or holds the numbers itself, works out any running mean with numpy, and saves the figure at the same size.

About the GROMACS .xvg format

.xvg is the plain-text output written by GROMACS analysis tools (and read by Grace/xmgrace). Knowing its structure explains what this tool does automatically.

Comment & metadata lines

Lines starting with # are comments; lines starting with @ are Grace formatting commands. This tool reads @ title, @ xaxis label, @ yaxis label and @ sN legend to label the plot, and skips everything else, so the raw numeric matrix is all that gets plotted. A line starting with & ends one data set, and a file may hold several: each is plotted as series of its own, against its own first column, under the legend GROMACS and Grace give it (sets are numbered through the file as xmgrace -nxy numbers them, so two columns in two sets are s0 and s1). A row with text in it, an empty cell in a CSV, or a different number of values from most rows is skipped whole and counted in the file summary at the top of the settings, so no value moves into the wrong column. A comma at the end of every row is ignored.

The data block

Below the metadata is a whitespace-separated numeric table: the first column is usually the independent variable (time, distance, reaction coordinate) and each remaining column a data series. Common outputs include RMSD (gmx rms), radius of gyration (gmx gyrate), and PMF/free-energy profiles.

Reproducing in Python

The Python script reads the file with numpy.loadtxt(..., comments=['@', '#', '&']), which is the idiomatic way to read an .xvg: the comments argument makes NumPy skip exactly the metadata lines and set breaks described above, leaving the numeric matrix. A file of several data sets is read set by set instead, the rows between its & lines into an array each, so that each series is drawn from its own rows. For a comma-separated file it also passes delimiter=',' and skips the header row. If the file has skipped rows among the numbers, the script passes loadtxt only the lines that are all numbers, so it reads the same rows as the plot. A running mean is numpy.convolve with a window of equal weights, and a lower panel is a second axes from plt.subplots(2, 1, sharex=True). The script sets the same fonts, sizes, colours, ticks and legend as the preview, which is drawn to match matplotlib 3.11 (the script runs on 3.6 and later).

References

References & documentation

  1. Abraham, M. J., Murtola, T., Schulz, R., et al. (2015). GROMACS: High performance molecular simulations through multi-level parallelism. SoftwareX, 1–2, 19–25. GROMACS file formats.
  2. Turner, P. J. (2005). XMGRACE (Grace 5.1). Center for Coastal and Land-Margin Research, OGI. (origin of the .xvg/@-command format)
  3. Harris, C. R., Millman, K. J., van der Walt, S. J., et al. (2020). Array programming with NumPy. Nature, 585, 357–362. numpy.loadtxt.
  4. Software: Plotly.js draws the preview; the script uses matplotlib and NumPy.