Hello!
I’ve been trying to solve this my self for a while and did some research, but wasn’t able to find the answer.
I need to animate a 3D surface plot. I have a 3-dimentional array of data for u(x, y, t), so I want to plot u(x, y) for each t and then observe the animation. I found a work around that I don’t really like. Do you guys know is there a proper way of doing the same in plotly? Here is my solution:
from plotly.offline import iplot
import ipywidgets as widgets
import time
from IPython.display import display
fig = go.FigureWidget(layout = layout)
surface = fig.add_surface(x = solver.x, y = solver.y, z=solver.u[0].T, colorscale = ‘YlGnBu’)
fig.layout.scene.zaxis.range = [np.min(solver.u), np.max(solver.u)]
fig.layout.scene.yaxis.range = [solver.Y_START, solver.Y_END]
fig.layout.scene.xaxis.range = [solver.X_START, solver.X_END]
def set_surface(i=0):
surface.z = solver.u[i].T
display(fig)
for i in range(solver.J):
set_surface(i)
time.sleep(0.2)
as you can see it will only work once when running the last loop.
solver is an atribute of my class with all the data inside.
Thanks in advance for your help!