Lines splines in graphic of values but y
Question: I would like to generate a graph like the link below

<http://en.wikipedia.org/wiki/Reaction_coordinate>

The graph generated from a calculation of the python library installed. I
would like the line is smooth with type cspline gnuplot

The values E_ads=234.4211 , E_dis=0.730278 and E_reac=-0.8714

Could anyone help me

    
    
    from ase import *
    from ase.calculators.jacapo import *
    import Gnuplot as gp
    # -- Read in all energies
    datadict = {'H2O' :'water.nc',
                'Pt' :'out-Pt.nc',
                'H2OPt' :'H2O.Pt.nc',
                'OHPt' :'OHPt.nc',
                'HPt' :'HPt.nc',
    }
    E = {}
    
    for label, file in datadict.items():
        print 'Reading energy for %5s from file %20s' % (label, file),
        atoms = Jacapo.read_atoms(file)
        E[label] = atoms.get_potential_energy()
        print '\tE = %14.6f eV'% E[label]
    print     
    
    # -- Calculate adsorption and disassociation energies
    E_ads = (E['H2OPt'] - 2*E['H2O'] - E['Pt'])/2
    print 'H2O adsorption energy on Pt:'
    print 'E_ads =', E_ads, 'eV\n'
    
    E_dis = E['HPt'] - E['Pt'] + E['OHPt'] - E['Pt'] - E['H2O']
    print 'H2O -> OH + H disassociation energy on Pt:'
    print 'E_dis =', E_dis, 'eV\n'
    
    E_reac = E['H2OPt'] - E['HPt'] - E['OHPt'] + E['Pt']
    print 'H2O@Pt -> OH@Pt +H@Pt reaction energy on Pt:'
    print 'E_reac =', E_reac, 'eV\n'
    # -- Collect reaction path
    Epath = np.asarray([1.0, E_ads, E_dis, E_reac])
    PathLabels= ['']
    # -- Plot the reaction path
    import pylab as p
    import numpy as np
    import matplotlib.path as mpath
    import matplotlib.patches as mpatches
    import matplotlib.pyplot as plt
    from scipy.interpolate import spline
    import matplotlib.pyplot as plt
    from numpy import array, linspace
    from scipy.interpolate import spline
    fig = p.figure(1)
    sp = p.subplot(1,1,1)
    p.plot(Epath, color='black', linestyle=':', linewidth=2.0, alpha=0.8)
    p.text(0.37, 10.05, 'Free H$_2$O',fontsize=12, color='black',ha='right', va='bottom', alpha=1.0)
    p.text(1.1, 238, 'H$_2$O + Pt',fontsize=12, color='black',ha='right', va='bottom', alpha=1.0)
    p.title('H$_2$O disassociation')
    p.ylabel('Energy [eV]')
    p.xlabel('Reaction path')
    #p.xlim([-0.5, 2.5])
    #p.ylim([-0.5, 1.5])
    sp.get_xaxis().set_ticks([]) # Turn off ticks on xaxis
    #p.savefig('Teste.png')
    p.show()
    


Answer: You can plot a regular cubic spline version of your data by just doing
something like this:

    
    
    plot(np.linspace(0,3),spline([0,1,2,3],Epath,np.linspace(0,3)))
    

which will yield something like:

![enter image description here](http://i.stack.imgur.com/GR4lU.png)

But I suspect that isn't what you want. You might need to resort to something
like [Monotone
splines](http://en.wikipedia.org/wiki/Monotone_cubic_interpolation) or [shape
preserving
splines](http://scholar.google.com/scholar?q=shape%20preserving%20spline&hl=en&as_sdt=0&as_vis=1&oi=scholart)
to get the shape which looks the same as those curves shown in your Wikipedia
link. I don't believe either of those interpolation methods are presently
implemented in scipy.

If you have a rough idea of the mathematical form of those curves, you could
always fit your own approximate function for the continuous section and just
clamp the function outside of that range. For example:

    
    
    plot(np.linspace(0,3),np.maximum(E_react,spline([0,1,2,3],Epath,np.linspace(0,3))))
    

would yield:

![enter image description here](http://i.stack.imgur.com/A699y.png)

which at least "looks" like the curve you linked to, even if it isn't the
correct fit.

