# Plotting a distance vs time graph

**URL:** <https://gromacs.bioexcel.eu/t/plotting-a-distance-vs-time-graph/821>\
**Category:** User discussions\
**Created:** [September 16, 2020, 3:45am UTC](https://gromacs.bioexcel.eu/t/plotting-a-distance-vs-time-graph/821 "2020-09-16T03:45:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![D429321](https://avatars.discourse-cdn.com/v4/letter/d/958977/32.png) [@D429321](https://gromacs.bioexcel.eu/u/D429321)\
**Post date:** [September 16, 2020, 3:45am UTC](https://gromacs.bioexcel.eu/t/plotting-a-distance-vs-time-graph/821/1 "2020-09-16T03:45:39Z")

</div>

GROMACS version: 2020.1  
GROMACS modification: Yes/No

Hi,

I am a beginner in Gromacs. I have performed the protein-ligand simulation given in the official GROMACS Tutorials website. I want to calculate the distance between binding site residues of the protein and the ligand during the MD simulation. I have used the command “gmx distance -s md\_0\_10.tpr -f md\_0\_10\_center.xtc -select ‘resname “JZ4” and name OAB plus resid 102 and name OE1’ -oall” and I have got the average distance value. However, I have seen many published papers where researchers plot the distance vs time graph. Hence, I would also like to know the specific script for obtaining such a graph.

Thanks in advance  
Regards

---

<div class="post-metadata">

**Author:** ![Dr\_DBW](https://dub1.discourse-cdn.com/flex017/user_avatar/gromacs.bioexcel.eu/dr_dbw/32/42_2.png) [@Dr\_DBW](https://gromacs.bioexcel.eu/u/Dr_DBW)\
**Post date:** [September 16, 2020, 4:01am UTC](https://gromacs.bioexcel.eu/t/plotting-a-distance-vs-time-graph/821/2 "2020-09-16T04:01:08Z")

</div>

[http://manual.gromacs.org/documentation/current/onlinehelp/gmx-distance.html](http://manual.gromacs.org/documentation/current/onlinehelp/gmx-distance.html)

> `gmx distance` calculates distances between pairs of positions as a function of time.

> -oall [\<.xvg\>] (dist.xvg) (Optional  
> All distances as function of time

You’ve already calculated it. Simply plot the values within the output file.

---

<div class="post-metadata">

**Author:** ![D429321](https://avatars.discourse-cdn.com/v4/letter/d/958977/32.png) [@D429321](https://gromacs.bioexcel.eu/u/D429321)\
**Post date:** [September 16, 2020, 9:09am UTC](https://gromacs.bioexcel.eu/t/plotting-a-distance-vs-time-graph/821/3 "2020-09-16T09:09:48Z")

</div>

Thank you very much for the reply. Since I am very new to GROMACS I am still learning the scripts and commands. It would be of great help to me if you could elaborate your answer or just mention the exact command that I need to give as an input.  
Thanks and regards

---

<div class="post-metadata">

**Author:** ![Dr\_DBW](https://dub1.discourse-cdn.com/flex017/user_avatar/gromacs.bioexcel.eu/dr_dbw/32/42_2.png) [@Dr\_DBW](https://gromacs.bioexcel.eu/u/Dr_DBW)\
**Post date:** [September 16, 2020, 9:27am UTC](https://gromacs.bioexcel.eu/t/plotting-a-distance-vs-time-graph/821/4 "2020-09-16T09:27:20Z")

</div>

You don’t have to run any script again, you already have the results in the output file that you generated when you ran `gmx distance`.

Since you didn’t specify any file name when you ran the command with the `-oall` switch, suspect the distance versus time data will be contained within the `dist.xvg` file.

---

<div class="post-metadata">

**Author:** ![D429321](https://avatars.discourse-cdn.com/v4/letter/d/958977/32.png) [@D429321](https://gromacs.bioexcel.eu/u/D429321)\
**Post date:** [September 16, 2020, 3:14pm UTC](https://gromacs.bioexcel.eu/t/plotting-a-distance-vs-time-graph/821/5 "2020-09-16T15:14:45Z")

</div>

Thank you for the reply. Yes, there is a file named “dist.xvg” in my working directory. I used the command xmgrace dist.xvg and got the graph. Thanks for the timely help.

Regards
