Created
January 18, 2018 23:03
-
-
Save mattwthompson/617113a37d49fc3d64969be757c401f6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
histo = np.loadtxt('histo.xvg', comments=['#', '@']) | |
x_values = histo[:, 0] | |
plt.figure(figsize=(10, 4)) | |
for hist in histo[:, 1:].T: | |
hist = [float('nan') if x==0 else x for x in hist] # Don't plot zero values | |
plt.plot(x_values, hist, '.-') | |
plt.xlabel('COM separation, nm') | |
plt.ylabel('Histogram counts, a.u.') | |
plt.savefig('histo.pdf') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Context: PMFs obtained via umbrella sampling in GROMACS rely on inverting histograms with WHAM. GROMACS is great for preparing, running, and analyzing these simulations. However, the raw histogram data are thrown to xvg files, which requires not only xmgrace to be installed and working properly, but some magic to actually plot all columns at once. This snippet avoids that.