Open main menu

Changes

Matplotlib example

1,933 bytes added, 17:07, 14 January 2014
plt.plot(resi_data, kex_data, 'ro')
plt.show()
</source>
 
== Example 2 ==
 
File: '''mat_example.py'''
<source lang="python">
# Get the OS path separator
from os import sep
# Plotting facility.
import matplotlib.pyplot as plt
 
# Import some tools to loop over the spins.
from pipe_control.mol_res_spin import return_spin, spin_loop
# Load the state
#state.load('final_state.bz2', force=True)
 
outfile = open("test.txt", "w")
 
# Ini
spectrometer_frq = cdp.spectrometer_frq_list[0]
cpmg_frqs_list = cdp.cpmg_frqs_list
sel_point = cpmg_frqs_list[1]
 
resi_data = []
Rex_data = []
Model_data = []
for resiob in cdp.mol[0].res:
cur_model = resiob.spin[0].model
if cur_model == "TSMFK01" :
r2dic=resiob.spin[0].r2a
for key, value in r2dic.iteritems():
r2a = value
elif cur_model == "CR72 full":
r2dic=resiob.spin[0].r2a
for key, value in r2dic.iteritems():
r2a = value
else:
r2dic=resiob.spin[0].r2
for key, value in r2dic.iteritems():
r2a = value
 
r2effdic = resiob.spin[0].r2eff
for key, value in r2effdic.iteritems():
curcpmg = float(key.split("_")[-1])
if curcpmg == sel_point:
r2eff = value
 
Rex = r2eff - r2a
 
print(resiob.name, resiob.num, cur_model, r2a, r2eff, Rex)
outfile.write("%s %s %s %s %s %s\n"%(resiob.name, resiob.num, cur_model.replace (" ", "_"), r2a, r2eff, Rex))
 
resi_data.append(resiob.num)
Rex_data.append(Rex)
Model_data.append(cur_model)
 
outfile.close()
 
plt.plot(resi_data, Rex_data, 'ro')
for i in range(len(resi_data)):
resi = resi_data[i]
Rex = Rex_data[i]
Model = Model_data[i]
if Model == "No Rex":
textcolor = 'k'
elif Model == "TSMFK01":
textcolor = 'r'
else:
textcolor = 'b'
 
plt.annotate('%s'%(resi), xy=(resi,Rex), xytext=(resi, Rex), size=8, color=textcolor)
plt.plot([min(resi_data), max(resi_data)], [0, 0], 'k-', lw=2)
 
plt.show()
</source>
Trusted, Bureaucrats
1,382

edits