Matplotlib example

From relax wiki
Jump to navigation Jump to search

Example

File: mat_example.py

# Get the OS path separator
from os import sep
# Find relax installation dir
from status import Status; status = Status()

# Import some tools to loop over the spins.
from pipe_control.mol_res_spin import return_spin, spin_loop

# Extra tools fo
import specific_analyses.relax_disp.disp_data as dtools

# Plotting facility.
import matplotlib.pyplot as plt

# Path to data
data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Hansen'+sep+'relax_results'

# Load the state
state.load(data_path+sep+'final_state.bz2', force=True)

# Loop over the spins
for spin, spin_id in spin_loop(return_id=True):
    print spin, spin_id

# Get the available data for a spin.
print(dir(spin))

resi_data = []
kex_data = []
for resiob in cdp.mol[0].res:
    print resiob.name, resiob.num, resiob.spin[0].kex, resiob.spin[0].model
    resi_data.append(resiob.num), kex_data.append(resiob.spin[0].kex)

print(dir(resiob))

plt.plot(resi_data, kex_data, 'ro')
plt.show()

To run

relax mat_example.py

Or

$ relax
relax> script('mat_example.py')

See also