Difference between revisions of "Relax disp.spin lock offset+field figure"
Jump to navigation
Jump to search
(Created page with "== Script to produce figure == <source lang="python"> ############# # Made by Troels E. Linnet # PhD student # Copenhagen University # SBiNLab, Structural Biology and NMR La...") |
(→See also: Fix for the category.) |
||
| (11 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
| + | {{lowercase title}} | ||
| + | |||
| + | __TOC__ | ||
| + | |||
| + | == Reference to original figure == | ||
| + | Comparing to Figure 1 and 10 the reference: | ||
| + | |||
| + | * {{#lst:Citations|PalmerMassi06}} | ||
| + | |||
| + | [[File:Fig1 Palmer Massi 2006.png|thumb|center|upright=4|Try to reproduce Figure 1.]] | ||
| + | |||
== Script to produce figure == | == Script to produce figure == | ||
| − | + | {{collapsible script | |
| − | + | | type = Python script | |
| + | | title = Reproduce figure 1 of Palmer and Massi, 2006 using matplotlib. | ||
| + | | lang = python | ||
| + | | script = | ||
############# | ############# | ||
# Made by Troels E. Linnet | # Made by Troels E. Linnet | ||
| Line 108: | Line 122: | ||
label = labels[i] | label = labels[i] | ||
label.xy = tX[i],tY[i] | label.xy = tX[i],tY[i] | ||
| + | label.update_positions(fig.canvas.renderer) | ||
| + | tX_t, tY_t, _ = proj3d.proj_transform(dataX_t, dataY_t, dataZ_t, ax.get_proj()) | ||
| + | for i in range(len(dataX_t)): | ||
| + | label = labels_t[i] | ||
| + | label.xy = tX_t[i],tY_t[i] | ||
label.update_positions(fig.canvas.renderer) | label.update_positions(fig.canvas.renderer) | ||
fig.canvas.draw() | fig.canvas.draw() | ||
| Line 114: | Line 133: | ||
######### | ######### | ||
| − | fig = plt.figure() | + | fig = plt.figure(figsize=(12, 12)) |
ax=fig.gca(projection='3d') | ax=fig.gca(projection='3d') | ||
| Line 127: | Line 146: | ||
ax.add_patch(circle) | ax.add_patch(circle) | ||
#art3d.pathpatch_2d_to_3d(circle, z=0, zdir='y') | #art3d.pathpatch_2d_to_3d(circle, z=0, zdir='y') | ||
| − | pathpatch_2d_to_3d(circle, z=0, normal = | + | pathpatch_2d_to_3d(circle, z=0, normal = [1, 0, 1] ) |
| + | |||
| + | ####### | ||
#Input 3D Data for Text | #Input 3D Data for Text | ||
| − | + | Sx = [1,0,0] | |
| − | + | Sy = [0,-1,0] | |
| + | Sz = [0,0,1] | ||
| + | Szp = [1.1,0,1.1] | ||
| + | Sxp = [0.75,0,-0.75] | ||
| + | w1 = [0.7,0,0] | ||
| + | O1 = [0,0,0.3] | ||
| + | we1 = [w1[0],0,O1[2]] | ||
| + | O_av = [0.0,0,Szp[2]/Szp[0]*w1[0]] | ||
| + | we = [w1[0],0,Szp[2]/Szp[0]*w1[0]] | ||
| + | |||
| + | data = np.array([Sx, Sy, Sz , Szp , Sxp, w1, O1, we1, O_av, we]) | ||
textlab = [r"S$_x$", r"S$_y$=S$_y$'", r"S$_z$", r"S$_z$'", r"S$_x$'", r"$\omega_1$", r"$\Omega_1$", r"$\omega_{e1}$", r"$\bar{\Omega}$", r"$\omega_{e}$"] | textlab = [r"S$_x$", r"S$_y$=S$_y$'", r"S$_z$", r"S$_z$'", r"S$_x$'", r"$\omega_1$", r"$\Omega_1$", r"$\omega_{e1}$", r"$\bar{\Omega}$", r"$\omega_{e}$"] | ||
| Line 147: | Line 178: | ||
#Array of labels | #Array of labels | ||
labels = [] | labels = [] | ||
| − | |||
#Loop through data points to initially annotate scatter plot | #Loop through data points to initially annotate scatter plot | ||
#and populate labels array | #and populate labels array | ||
| Line 155: | Line 185: | ||
label = ax.annotate(text, | label = ax.annotate(text, | ||
xycoords='data', | xycoords='data', | ||
| − | xy = (tX[i], tY[i]), xytext = ( | + | xy = (tX[i], tY[i]), xytext = (+20, -20), |
textcoords = 'offset points', ha = 'right', va = 'top', fontsize=12, | textcoords = 'offset points', ha = 'right', va = 'top', fontsize=12, | ||
bbox = dict(boxstyle = 'round,pad=0.5', fc = 'grey', alpha = 0.8), | bbox = dict(boxstyle = 'round,pad=0.5', fc = 'grey', alpha = 0.8), | ||
arrowprops = dict(arrowstyle = '->', connectionstyle = 'arc3,rad=0')) | arrowprops = dict(arrowstyle = '->', connectionstyle = 'arc3,rad=0')) | ||
labels.append(label) | labels.append(label) | ||
| + | ####### | ||
| + | |||
| + | ####### | ||
| + | #Input 3D Data for Ttheta | ||
| + | |||
| + | t1 = [0.5*we1[0],0,0.5*we1[2]] | ||
| + | t = [0.5*we[0],0,0.5*we[2]] | ||
| + | |||
| + | data_t = np.array([t1, t]) | ||
| + | textlab_t = [r"$\theta_1$", r"$\theta$"] | ||
| + | |||
| + | #Separate into X, Y, Z for greater clarity | ||
| + | dataX_t = data_t[:,0] | ||
| + | dataY_t = data_t[:,1] | ||
| + | dataZ_t = data_t[:,2] | ||
| + | |||
| + | #3D scatter plot | ||
| + | ax.scatter(dataX_t, dataY_t, dataZ_t, marker = 'o', c='k', s=1) | ||
| + | |||
| + | #Transform co-ordinates to get initial 2D projection | ||
| + | tX_t, tY_t, _ = proj3d.proj_transform(dataX_t, dataY_t, dataZ_t, ax.get_proj()) | ||
| + | |||
| + | #Array of labels | ||
| + | labels_t = [] | ||
| + | #Loop through data points to initially annotate scatter plot | ||
| + | #and populate labels array | ||
| + | for i in range(len(dataX_t)): | ||
| + | #text='['+str(int(dataX[i]))+','+str(int(dataY[i]))+','+str(int(dataZ[i]))+']' | ||
| + | text=textlab_t[i] | ||
| + | label = ax.annotate(text, | ||
| + | xycoords='data', | ||
| + | xy = (tX[i], tY[i]), xytext = (-100, 50), | ||
| + | textcoords = 'offset points', ha = 'right', va = 'top', fontsize=12, | ||
| + | bbox = dict(boxstyle = 'round,pad=0.5', fc = 'grey', alpha = 0.8), | ||
| + | arrowprops = dict(arrowstyle = '->', connectionstyle = 'angle3,angleA=0,angleB=90')) | ||
| + | labels_t.append(label) | ||
| + | ####### | ||
| + | |||
| + | |||
# Make Sx | # Make Sx | ||
| − | + | x, y, z = Sx | |
| − | Sx = Arrow3D([-1, | + | Sx = Arrow3D([-1, x],[0, y], [0, z], mutation_scale=20, lw=1, arrowstyle="-{{!}}>", color="k") |
ax.add_artist(Sx) | ax.add_artist(Sx) | ||
# Make Sy | # Make Sy | ||
| − | + | x, y, z = Sy | |
| − | + | fSy = Arrow3D([0, x],[1, y], [0, z], mutation_scale=20, lw=1, arrowstyle="-{{!}}>", color="k") | |
| − | ax.add_artist( | + | ax.add_artist(fSy) |
# Make Sz | # Make Sz | ||
| − | + | x, y, z = Sz | |
| − | + | fSz = Arrow3D([0, x],[0, y], [-1, z], mutation_scale=20, lw=1, arrowstyle="-{{!}}>", color="k") | |
| − | ax.add_artist( | + | ax.add_artist(fSz) |
# Make Szp | # Make Szp | ||
| − | + | x, y, z = Szp | |
| − | + | fSzp = Arrow3D([0, x],[0, y], [0, z], mutation_scale=20, lw=3, arrowstyle="-{{!}}>", color="k") | |
| − | ax.add_artist( | + | ax.add_artist(fSzp) |
# Make Sxp | # Make Sxp | ||
| − | + | x, y, z = Sxp | |
| − | + | fSxp = Arrow3D([0, x],[0, y], [0, z], mutation_scale=20, lw=3, arrowstyle="-{{!}}>", color="k") | |
| − | ax.add_artist( | + | ax.add_artist(fSxp) |
# Make w1 | # Make w1 | ||
| − | + | x, y, z = w1 | |
| − | + | fw1 = Arrow3D([0, x],[0, y], [0, z], mutation_scale=20, lw=1, arrowstyle="-", color="k") | |
| − | ax.add_artist( | + | ax.add_artist(fw1) |
# Make O1 | # Make O1 | ||
| − | + | x, y, z = O1 | |
| − | + | fO1 = Arrow3D([0, x],[0, y], [0, y], mutation_scale=20, lw=1, arrowstyle="-", color="k") | |
| − | ax.add_artist( | + | ax.add_artist(fO1) |
# Make we1 | # Make we1 | ||
| − | + | x, y, z = we1 | |
| − | we1 = Arrow3D([0, | + | fwe1 = Arrow3D([0, x],[0, y], [0, z], mutation_scale=20, lw=1, arrowstyle="-{{!}}>", color="b") |
| − | ax.add_artist( | + | ax.add_artist(fwe1) |
| + | |||
| + | # Make O1 -> we1 | ||
| + | fO1_we1 = Arrow3D([O1[0], we1[0]],[O1[1], we1[1]], [O1[2], we1[2]], mutation_scale=20, lw=1, arrowstyle="-", color="b") | ||
| + | ax.add_artist(fO1_we1) | ||
# Make O_av | # Make O_av | ||
| − | + | x, y, z = O_av | |
| − | + | fO_av = Arrow3D([0, x],[0, y], [0, z], mutation_scale=20, lw=1, arrowstyle="-", color="k") | |
| − | ax.add_artist( | + | ax.add_artist(fO_av) |
# Make we | # Make we | ||
| − | + | x, y, z = we | |
| − | we = Arrow3D([0, | + | fwe = Arrow3D([0, x],[0, y], [0, z], mutation_scale=20, lw=1, arrowstyle="-{{!}}>", color="r") |
| − | ax.add_artist( | + | ax.add_artist(fwe) |
| + | |||
| + | # Make w1 -> we | ||
| + | fw1_we = Arrow3D([w1[0], we[0]],[w1[1], we[1]], [w1[2], we[2]], mutation_scale=20, lw=1, arrowstyle="-", color="r") | ||
| + | ax.add_artist(fw1_we) | ||
| + | |||
| + | # Make O_ave -> we | ||
| + | fO_av_we = Arrow3D([O_av[0], we[0]],[O_av[1], we[1]], [O_av[2], we[2]], mutation_scale=20, lw=1, arrowstyle="-", color="r") | ||
| + | ax.add_artist(fO_av_we) | ||
| Line 218: | Line 299: | ||
fig.canvas.mpl_connect('button_release_event', update_position) | fig.canvas.mpl_connect('button_release_event', update_position) | ||
plt.show() | plt.show() | ||
| − | + | }} | |
| + | |||
| + | == See also == | ||
| + | |||
| + | [[Category:Relaxation dispersion analysis]] | ||
Latest revision as of 17:35, 6 November 2015
Reference to original figure
Comparing to Figure 1 and 10 the reference:
- Palmer, 3rd, A. G. and Massi, F. (2006). Characterization of the dynamics of biomacromolecules using rotating-frame spin relaxation NMR spectroscopy. Chem. Rev., 106(5), 1700-1719. (DOI: 10.1021/cr0404287)
Script to produce figure
Python script: Reproduce figure 1 of Palmer and Massi, 2006 using matplotlib.
