Python script to plot 3D FEL plots

 # To plot FEL in 3D use this python script and run as python2.7 fel3d.py. Here the file uses gibbs.txt. therefore before running the script make sure u have the gibbs.txt in the same folder of this script or else provide the location of the script. 

I have attached some images from my research article using the same script for 3D FEL plot

These plots are published in Interplay among Structural Stability, Plasticity, and Energetics Determined by Conformational Attuning of Flexible Loops in PD-1

The 2D FEL scripts are also mentioned in the next blog: Python script to plot 2D FEL







Another point to consider is: when u r plotting FEL plots for multiple systems, make sure your color bar/gradient should be same in all the plots. So u can change the values in vmax,  ax.set_zlim(0, 18),  ticks=range(0, 21, 2)) in the script below. Like in my case the highest value was 18 in gibbs free energy (the z axis) in all the axis. therefore i mentioned 18 there. ticks range also u need to change accordingly. Otherwise, u can try other commands also which I have commented in the script.

cset = ax.contourf(X1, Y1, Z, zdir='z', offset=-0, cmap=cm.jet, antialiased=3, vmin=0, vmax=18)
ax.set_zlim(0, 18)
fig.colorbar(cset, shrink=0.8, aspect=20, extend='neither', ticks=range(0, 21, 2))

Below is the script fel3d.py:


## FEL using plot_surface


import numpy as np

from mpl_toolkits.mplot3d import Axes3D

import matplotlib.pyplot as plt

import random

from matplotlib import cm

from scipy.interpolate import griddata

from scipy.interpolate import Rbf

from numpy import linspace

#from matplotlib.ticker import LinearLocator, FormatStrFormatter

import matplotlib

from scipy import interpolate

import matplotlib.mlab as ml

fig = plt.figure(figsize=None, dpi=300, facecolor=None, edgecolor=None, linewidth=0.0, frameon=None, subplotpars=None, tight_layout=None)

ax = fig.add_subplot(111, projection='3d')

### input file with x,y,z coordinates

x,y,z = np.loadtxt('gibbs.txt').T 

X,Y = np.unique(x),np.unique(y)

xi = linspace(min(X),max(X),len(X))

yi = linspace(min(Y),max(Y),len(Y))

xi,yi = np.meshgrid(xi,yi)

X1, Y1 = np.meshgrid(X,Y)

print (len(x))

Z = griddata((x,y),z,(X1,Y1),method='cubic')

surf = ax.plot_surface(X1, Y1, Z, rstride=1,cstride=1,alpha=1,cmap=cm.jet, linewidth=0.0, antialiased=3)

cset = ax.contourf(X1, Y1, Z, zdir='z', offset=-0, cmap=cm.jet, antialiased=3, vmin=0, vmax=18)

### put name of each axis. Cgange fontsize and lablesize accordingly

ax.set_xlabel('PC1',fontsize=12)

#ax.set_xlim(-6, 6)

ax.tick_params(axis="x", labelsize=6)

ax.set_ylabel('PC2',fontsize=12)

#ax.set_ylim(-6, 6)

ax.tick_params(axis="y", labelsize=6)

#ax.set_zlabel('Z axis', fontsize=12)

ax.tick_params(axis="z", labelsize=6)

ax.set_zlim(0, 18)


# Add a color bar which maps values to colors.

#fig.colorbar(surf, shrink=0.8, aspect=20)

#fig.colorbar(surf, shrink=0.8, aspect=20, extend='neither', ticks=[0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20])

fig.colorbar(cset, shrink=0.8, aspect=20, extend='neither', ticks=range(0, 21, 2))

#fig.colorbar(surf, shrink=0.8, aspect=20, ticks=[0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20])

#fig.clim(0.0,20.0)

plt.show()




For any queries regarding the script, kindly drop your message in the comments section below.

Please also provide your valuable feedback and stay tuned for more such blogs and scripts!!

Happy Computing!!



Comments

  1. i get this error ''$ python3 fel3d.py
    qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
    This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

    Available platform plugins are: eglfs, minimal, minimalegl, offscreen, vnc, webgl, xcb.

    Aborted""

    ReplyDelete

Post a Comment

Popular posts from this blog

Calculation of RMSD values between two ligand poses using web servers/tools

AMBER TUTORIAL-2: How to simulate a protein- ligand system: basic steps for md simulation in amber (AMBER 16)