I have a GROMACS trajectory of MD simulation. I want to make a contour plot of density as a function of two coordinates, namely X and Z. Is it possible to get this using gmx density? If not, is there any other way?


2 Answers 2


gmx density can help in finding partial densities either along a particular axis (generally z axis) or with respect to the center of the box. It does not make a contour plot. However, gmx densmap can be used for computing 2D density maps. Both the commands need trajectory file as input files.

  • 1
    $\begingroup$ Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center. $\endgroup$
    – Community Bot
    Dec 20, 2022 at 14:29

You can use gmx-densmap and set the average along the y-axis to get the contour plot showing the density as a function of the x and z-axis and the average over the y-axis.

Use the command as :

gmx densmap -f trj.trr -s trj.tpr -o densmap.xpm -aver y -n index.ndx -bin 0.01

Use index.ndx to calculate the density of a selected atom or molecule.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .