From 0fc12db36a159976ee0e16e9e1e97f15bc1127a7 Mon Sep 17 00:00:00 2001 From: Amir Mirzanejad <aqm6884@psu.edu> Date: Thu, 7 Sep 2023 16:12:56 -0400 Subject: [PATCH] Notebook for Plotly plots in figures 2 and 4 --- Plotly_plots.ipynb | 133 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 Plotly_plots.ipynb diff --git a/Plotly_plots.ipynb b/Plotly_plots.ipynb new file mode 100644 index 0000000..83931c1 --- /dev/null +++ b/Plotly_plots.ipynb @@ -0,0 +1,133 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 4, + "id": "99d587ca-7160-4848-8ee1-858ee39ad93f", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "<iframe\n", + " scrolling=\"no\"\n", + " width=\"1020px\"\n", + " height=\"1020\"\n", + " src=\"iframe_figures/figure_4.html\"\n", + " frameborder=\"0\"\n", + " allowfullscreen\n", + "></iframe>\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "# improt dependecies\n", + "import plotly\n", + "import plotly.io as pio\n", + "pio.renderers.default = \"iframe\"\n", + "\n", + "# The data array called \"data\"\n", + "data = [\n", + " [0.0, 0.1, 0.1, 0.0, 0.0, -0.1, -0.1, -0.1, 0.0, 0.0, 0.0, 0.0],\n", + " [0.1, 0.1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],\n", + " [0.6, 0.6, 0.6, 0.7, 0.6, 0.5, 0.3, 0.2, 0.2, 0.3, 0.3, 0.4],\n", + " [2.4, 2.0, 1.7, 1.4, 1.1, 0.8, 0.7, 0.6, 0.6, 0.7, 0.7, 0.7],\n", + " [5.8, 4.9, 4.2, 3.4, 2.5, 1.7, 1.2, 0.9, 0.8, 0.8, 0.8, 0.9],\n", + " [11.2, 9.5, 7.6, 5.5, 3.7, 2.5, 1.8, 1.3, 1.1, 1.1, 1.1, 1.2],\n", + " [19.9, 17.7, 15.6, 13.4, 10.9, 8.0, 4.8, 2.8, 1.9, 1.5, 1.4, 1.5],\n", + " [47.3, 41.0, 34.5, 28.9, 24.2, 19.8, 15.2, 10.9, 7.0, 3.7, 2.0, 1.6],\n", + " [65.0, 60.9, 53.3, 43.6, 33.3, 24.2, 16.4, 10.6, 6.5, 3.9, 2.5 , 2.2],\n", + " [66.0, 65.2, 61.7, 54.8, 45.1, 36.1, 27.5, 19.5, 12.4, 6.7, 3.6, 2.9],\n", + " [66.0, 65.4, 61.6, 53.6, 43.5, 33.2, 23.5, 15.5, 9.6, 5.5, 3.4, 3.0],\n", + " [66.0, 65.8, 63.3, 57.0, 48.3, 38.8, 29.6, 21.1, 13.7, 7.8, 4.0, 3.1],\n", + " [64.6, 65.7, 67.0, 66.0, 59.4, 48.9, 37.7, 27.2, 18.0, 10.8, 7.3, 6.7],\n", + " [63.3, 65.0, 67.6, 68.4, 62.9, 50.9, 38.1, 27.0, 18.6, 13.3, 10.8, 10.7],\n", + " [61.7, 63.3, 67.3, 70.3, 68.4, 58.4, 45.6, 34.2, 25.5, 19.7, 16.7, 16.7],\n", + " [59.4, 61.3, 65.7, 71.2, 73.7, 69.0, 59.1, 47.7, 37.2, 29.1, 25.3, 24.8],\n", + " [56.5, 58.9, 64.7, 72.8, 78.7, 77.8, 70.7, 60.2, 50.5, 42.3, 37.6, 36.2],\n", + " [52.7, 54.9, 61.6, 70.4, 80.6, 89.1, 89.3, 79.6, 67.6, 57.3, 50.4, 48.6],\n", + " [42.9, 46.2, 56.1, 71.7, 91.1, 116.0, 123.5, 101.6, 79.0, 62.7, 51.7, 48.1]\n", + "]\n", + "\n", + "# Apply the Gaussian filter\n", + "sigma = [1.5, 2]\n", + "data_smooth = scipy.ndimage.gaussian_filter(data, sigma)\n", + "\n", + "# Mirror the data along the y-axis\n", + "data_smooth_symmetric = np.concatenate((np.fliplr(data_smooth), data_smooth), axis=1)\n", + "\n", + "# Define custom color scale\n", + "colorscale = [[0, 'orange'], [1, 'yellow']]\n", + "\n", + "fig = go.Figure()\n", + "\n", + "# Generate x and y indices\n", + "x = np.linspace(-1, 1, data_smooth_symmetric.shape[1])\n", + "y = np.linspace(0, 1, data_smooth_symmetric.shape[0])\n", + "\n", + "# Add surface trace without contours, using the symmetric data\n", + "fig.add_trace(go.Surface(x=x, y=y, z=data_smooth_symmetric, colorscale=colorscale, showscale=True))\n", + "\n", + "# Add lines that correspond to constant y values\n", + "for i in range(data_smooth_symmetric.shape[0]):\n", + " fig.add_trace(go.Scatter3d(x=x, y=np.full_like(x, y[i]), z=data_smooth_symmetric[i, :], mode='lines', \n", + " line=dict(color='black', width=5), showlegend=False))\n", + "\n", + "# Add thick blue line at x=0\n", + "fig.add_trace(go.Scatter3d(x=np.full_like(y, 0), y=y, z=data_smooth_symmetric[:, data_smooth.shape[1]], mode='lines', \n", + " line=dict(color='blue', width=15), showlegend=False))\n", + "\n", + "# Add thick red lines at x=first and x=last\n", + "fig.add_trace(go.Scatter3d(x=np.full_like(y, -1), y=y, z=data_smooth_symmetric[:, 0], mode='lines', \n", + " line=dict(color='red', width=10), showlegend=False))\n", + "fig.add_trace(go.Scatter3d(x=np.full_like(y, 1), y=y, z=data_smooth_symmetric[:, -1], mode='lines', \n", + " line=dict(color='red', width=10), showlegend=False))\n", + "\n", + "# Adjust position of camera\n", + "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))\n", + "\n", + "fig.update_layout(scene_camera=camera_params)\n", + "\n", + "fig.update_layout(title='3D PES', autosize=True,\n", + " scene = dict(xaxis = dict(title='Geometry Interpolation between Paths', title_font_family=\"Arial\", title_font_color='black'), \n", + " yaxis = dict(title='Reaction Progress / a.u.', title_font_family=\"Arial\", title_font_color='black'),\n", + " zaxis = dict(title='Relative Energy / kcal mol', title_font_family=\"Arial\", title_font_color='black'),),\n", + " width=1000, height=1000, margin=dict(l=65, r=100, b=65, t=90))\n", + "\n", + "fig.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e8b23fb9-adba-416b-b21a-7cb4c3e3647a", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.8" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} -- GitLab