Skip to content
Snippets Groups Projects
Commit 20f209d7 authored by Amir Mirzanejad's avatar Amir Mirzanejad
Browse files

Update Plotly_plots.ipynb

parent 0fc12db3
No related branches found
No related tags found
No related merge requests found
%% Cell type:code id:99d587ca-7160-4848-8ee1-858ee39ad93f tags:
``` python
# improt dependecies
import plotly
import plotly.io as pio
pio.renderers.default = "iframe"
# The data array called "data"
# The data array called "data" for Figure 2, for instance
data = [
[0.0, 0.1, 0.1, 0.0, 0.0, -0.1, -0.1, -0.1, 0.0, 0.0, 0.0, 0.0],
[0.1, 0.1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
[0.6, 0.6, 0.6, 0.7, 0.6, 0.5, 0.3, 0.2, 0.2, 0.3, 0.3, 0.4],
[2.4, 2.0, 1.7, 1.4, 1.1, 0.8, 0.7, 0.6, 0.6, 0.7, 0.7, 0.7],
[5.8, 4.9, 4.2, 3.4, 2.5, 1.7, 1.2, 0.9, 0.8, 0.8, 0.8, 0.9],
[11.2, 9.5, 7.6, 5.5, 3.7, 2.5, 1.8, 1.3, 1.1, 1.1, 1.1, 1.2],
[19.9, 17.7, 15.6, 13.4, 10.9, 8.0, 4.8, 2.8, 1.9, 1.5, 1.4, 1.5],
[47.3, 41.0, 34.5, 28.9, 24.2, 19.8, 15.2, 10.9, 7.0, 3.7, 2.0, 1.6],
[65.0, 60.9, 53.3, 43.6, 33.3, 24.2, 16.4, 10.6, 6.5, 3.9, 2.5 , 2.2],
[66.0, 65.2, 61.7, 54.8, 45.1, 36.1, 27.5, 19.5, 12.4, 6.7, 3.6, 2.9],
[66.0, 65.4, 61.6, 53.6, 43.5, 33.2, 23.5, 15.5, 9.6, 5.5, 3.4, 3.0],
[66.0, 65.8, 63.3, 57.0, 48.3, 38.8, 29.6, 21.1, 13.7, 7.8, 4.0, 3.1],
[64.6, 65.7, 67.0, 66.0, 59.4, 48.9, 37.7, 27.2, 18.0, 10.8, 7.3, 6.7],
[63.3, 65.0, 67.6, 68.4, 62.9, 50.9, 38.1, 27.0, 18.6, 13.3, 10.8, 10.7],
[61.7, 63.3, 67.3, 70.3, 68.4, 58.4, 45.6, 34.2, 25.5, 19.7, 16.7, 16.7],
[59.4, 61.3, 65.7, 71.2, 73.7, 69.0, 59.1, 47.7, 37.2, 29.1, 25.3, 24.8],
[56.5, 58.9, 64.7, 72.8, 78.7, 77.8, 70.7, 60.2, 50.5, 42.3, 37.6, 36.2],
[52.7, 54.9, 61.6, 70.4, 80.6, 89.1, 89.3, 79.6, 67.6, 57.3, 50.4, 48.6],
[42.9, 46.2, 56.1, 71.7, 91.1, 116.0, 123.5, 101.6, 79.0, 62.7, 51.7, 48.1]
]
# Apply the Gaussian filter
sigma = [1.5, 2]
data_smooth = scipy.ndimage.gaussian_filter(data, sigma)
# Mirror the data along the y-axis
data_smooth_symmetric = np.concatenate((np.fliplr(data_smooth), data_smooth), axis=1)
# Define custom color scale
colorscale = [[0, 'orange'], [1, 'yellow']]
fig = go.Figure()
# Generate x and y indices
x = np.linspace(-1, 1, data_smooth_symmetric.shape[1])
y = np.linspace(0, 1, data_smooth_symmetric.shape[0])
# Add surface trace without contours, using the symmetric data
fig.add_trace(go.Surface(x=x, y=y, z=data_smooth_symmetric, colorscale=colorscale, showscale=True))
# Add lines that correspond to constant y values
for i in range(data_smooth_symmetric.shape[0]):
fig.add_trace(go.Scatter3d(x=x, y=np.full_like(x, y[i]), z=data_smooth_symmetric[i, :], mode='lines',
line=dict(color='black', width=5), showlegend=False))
# Add thick blue line at x=0
fig.add_trace(go.Scatter3d(x=np.full_like(y, 0), y=y, z=data_smooth_symmetric[:, data_smooth.shape[1]], mode='lines',
line=dict(color='blue', width=15), showlegend=False))
# Add thick red lines at x=first and x=last
fig.add_trace(go.Scatter3d(x=np.full_like(y, -1), y=y, z=data_smooth_symmetric[:, 0], mode='lines',
line=dict(color='red', width=10), showlegend=False))
fig.add_trace(go.Scatter3d(x=np.full_like(y, 1), y=y, z=data_smooth_symmetric[:, -1], mode='lines',
line=dict(color='red', width=10), showlegend=False))
# Adjust position of camera
camera_params = dict(up=dict(x=1.25,y=0,z=1), center=dict(x=0,y=0,z=0), eye=dict(x=2.25,y=-2.25,z=1.75))
fig.update_layout(scene_camera=camera_params)
fig.update_layout(title='3D PES', autosize=True,
scene = dict(xaxis = dict(title='Geometry Interpolation between Paths', title_font_family="Arial", title_font_color='black'),
yaxis = dict(title='Reaction Progress / a.u.', title_font_family="Arial", title_font_color='black'),
zaxis = dict(title='Relative Energy / kcal mol', title_font_family="Arial", title_font_color='black'),),
width=1000, height=1000, margin=dict(l=65, r=100, b=65, t=90))
fig.show()
```
%% Output
%% Cell type:code id:e8b23fb9-adba-416b-b21a-7cb4c3e3647a tags:
``` python
```
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment