Lowest curve plot below data cloudΒΆ

try pytraj online:

http://mybinder.org/badge.svg

../_images/lowest_curve.png
In [1]:
! head esurf_vs_rmsd.dat
2.14566	10.6364
1.80556	10.2486
1.70040	10.3254
1.82970	10.7363
2.52036	10.7145
2.57752	11.7054
2.21513	10.4196
2.38134	10.3821
2.26788	10.1739
2.73504	10.7062
In [2]:
import warnings
warnings.filterwarnings('ignore', category=DeprecationWarning)
import pytraj as pt
import numpy as np

# load energy and rmsd data
data = np.loadtxt('esurf_vs_rmsd.dat').T
data
Out[2]:
array([[  2.14566,   1.80556,   1.7004 , ...,   4.42627,   4.58734,
          4.1027 ],
       [ 10.6364 ,  10.2486 ,  10.3254 , ...,  10.8499 ,  11.1952 ,  11.58   ]])
In [3]:
lowest_data = pt.lowest_curve(data, points=10, step=0.2)
# skip final data points to have  nicer plot
lowest_data = lowest_data[:, :-5]
lowest_data
Out[3]:
array([[  0.34831   ,   0.54831   ,   0.74831   , ...,   7.34831   ,
          7.54831   ,   7.74831   ],
       [  9.38836   ,   9.20639   ,   9.16268   , ...,  13.88775714,
         13.6081    ,  14.8627    ]])

do plotting

In [4]:
%matplotlib inline
%config InlineBackend.figure_format = 'retina'  # high resolution
import matplotlib
matplotlib.rcParams['savefig.dpi'] = 2 * matplotlib.rcParams['savefig.dpi'] # larger image
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/Users/haichit/miniconda3/lib/python3.5/site-packages/matplotlib/rcsetup.py in validate_dpi(s)
    206     try:
--> 207         return float(s)
    208     except ValueError:

ValueError: could not convert string to float: 'figurefigure'

During handling of the above exception, another exception occurred:

ValueError                                Traceback (most recent call last)
/Users/haichit/miniconda3/lib/python3.5/site-packages/matplotlib/__init__.py in __setitem__(self, key, val)
    925             try:
--> 926                 cval = self.validate[key](val)
    927             except ValueError as ve:

/Users/haichit/miniconda3/lib/python3.5/site-packages/matplotlib/rcsetup.py in validate_dpi(s)
    209         raise ValueError('"%s" is not string "figure" or'
--> 210             ' could not convert "%s" to float' % (s, s))
    211 

ValueError: "figurefigure" is not string "figure" or could not convert "figurefigure" to float

During handling of the above exception, another exception occurred:

ValueError                                Traceback (most recent call last)
<ipython-input-4-c01d62fb780f> in <module>()
      2 get_ipython().magic("config InlineBackend.figure_format = 'retina'  # high resolution")
      3 import matplotlib
----> 4 matplotlib.rcParams['savefig.dpi'] = 2 * matplotlib.rcParams['savefig.dpi'] # larger image

/Users/haichit/miniconda3/lib/python3.5/site-packages/matplotlib/__init__.py in __setitem__(self, key, val)
    926                 cval = self.validate[key](val)
    927             except ValueError as ve:
--> 928                 raise ValueError("Key %s: %s" % (key, str(ve)))
    929             dict.__setitem__(self, key, cval)
    930         except KeyError:

ValueError: Key savefig.dpi: "figurefigure" is not string "figure" or could not convert "figurefigure" to float
In [5]:
from matplotlib import pyplot as plt

plt.plot(data[0], data[1], 'o', markersize=2., alpha=0.5)
plt.plot(lowest_data[0], lowest_data[1], linewidth=4.)
plt.xlabel('rmsd (angstrom)')
plt.ylabel('ESURF (kcal/mol)')
#plt.savefig('lowest_curve.png')
Out[5]:
<matplotlib.text.Text at 0x10a520828>

(basic_tutorial_lowestcurve.ipynb; basic_tutorial_lowestcurve_evaluated.ipynb; basic_tutorial_lowestcurve.py)