Monday, 1 November 2021

Animated 3D Surface Plots with Plotly

For research data visualisation I'd like to make an animated 3D surface plot in Plotly. The goal is to see the evolution of temperature in a box in function of time. But I don't know how to animate it.

At this moment I only have my plot at a give time. This is my code:

import plotly
import plotly.graph_objects as go
#import plotly.express as px
import pandas as pd
#import numpy as np

#read CSV
z_data = pd.read_csv('data1.csv')# Read data from a csv

fig = go.Figure(data=[go.Surface(z=z_data.values)])

#projection 2D
fig.update_traces(contours_z=dict(show=True, usecolormap=True,
                                  highlightcolor="tomato", project_z=True),
                                  colorscale='portland')

#fig
fig.update_layout(title='data HEATPILES', autosize=False, width=650, height=500, margin=dict(l=0, r=0, b=0, t=0))

#show
plotly.offline.plot(fig)

data1.csv is only this: data1.csv

But I have more data of the point's position in function of time and I would want to make an animated plot, so we could clearly see the evolution on time.

Here is the result at a given time Plot at a given time

I've seen on the plotly documentation that it's possible to make animation with px.scatter and px.line from here, and from there that we can do it with image, so I guess it would be possible with surface plot.

If you could help me do you I would much appreciate ! Thank you for your help,

Theophile



from Animated 3D Surface Plots with Plotly

No comments:

Post a Comment