Thank you for response! I’d like to keep previous points during animation just like @akroma
My code is identical to the one posted above
# select folder
root_folder = r'C:\Users\cepch\data'
well_names = os.listdir(root_folder)
df_drill_all = []
# Creating dict of wells where each key contains certain well and values represent X,Y,Z #coordinates
for well in well_names:
ds_data_path = os.path.join(os.path.join(root_folder, well), 'Deviation_Survey')
excel_file = os.listdir(ds_data_path)
if len(excel_file)!=0:
df = pd.read_excel(os.path.join(ds_data_path,excel_file[0]))
df_drill_all.append(df)
# df = pd.concat(df_drill_all).reset_index(drop=True)
well_dict = dict(zip(well_names,df_drill_all))
# Choosing just one well for the sake of time
cardiff = well_dict['Cardiff-1']
#getting coordinates from dataframe
x = cardiff.X.values
y = cardiff.Y.values
z = cardiff.Z.values
# copied from forum
fig = go.Figure(go.Scatter3d(x=[], y=[], z=[],
mode="markers",
marker=dict(color="red", size=20))
)
frames = [go.Frame(data= [go.Scatter3d(x=[x[:k+1]],
y=[y[:k+1]],
z=[z[:k+1]],
mode="markers",
marker=dict(color="red", size=20)
)
],
traces= [0],
name=f'frame{k}'
)for k in range(0,len(x)-1,100)
]
fig.update_layout(scene = dict(xaxis=dict(range=[min(x), max(x)], autorange=False,zeroline=False),
yaxis=dict(range=[min(y), max(y)], autorange=False,zeroline=False),
zaxis=dict(range=[min(z), max(z)], autorange=False,zeroline=False)
)
)
fig.update(frames=frames)
def frame_args(duration):
return {
"frame": {"duration": duration},
"mode": "immediate",
"fromcurrent": True,
"transition": {"duration": duration, "easing": "linear"},
}
sliders = [
{"pad": {"b": 10, "t": 60},
"len": 0.9,
"x": 0.1,
"y": 0,
"steps": [
{"args": [[f.name], frame_args(0)],
"label": str(k),
"method": "animate",
} for k, f in enumerate(fig.frames)
]
}
]
fig.update_layout(
updatemenus = [{"buttons":[
{
"args": [None, frame_args(10)],
"label": "Play",
"method": "animate",
},
{
"args": [[None], frame_args(0)],
"label": "Pause",
"method": "animate",
}],
"direction": "left",
"pad": {"r": 10, "t": 70},
"type": "buttons",
"x": 0.1,
"y": 0,
}
],
sliders=sliders
)
fig.update_layout(sliders=sliders)
fig.show()
Example of data
X Y Z
421293.4156 386343.3083 646.3804
421293.4156 386343.3083 646.5328
421293.4156 386343.3083 646.6852
421293.4156 386343.3083 646.8376
421293.4156 386343.3083 646.99
421293.4156 386343.3083 647.1424
421293.4156 386343.3083 647.2948
421293.4156 386343.3083 647.4472
421293.4156 386343.3083 647.5996
421293.4156 386343.3083 647.752
421293.4156 386343.3083 647.9044
421293.4156 386343.3083 648.0568
421293.4156 386343.3083 648.2092
421293.4156 386343.3083 648.3616
421293.4156 386343.3083 648.514
421293.4156 386343.3083 648.6664
421293.4156 386343.3083 648.8188
421293.4156 386343.3083 648.9712
421293.4156 386343.3083 649.1236
421293.4156 386343.3083 649.276
421293.4156 386343.3083 649.4284
421293.4156 386343.3083 649.5808
421293.4156 386343.3083 649.7332
421293.4156 386343.3083 649.8856
421293.4156 386343.3083 650.038
421293.4156 386343.3083 650.1904
421293.4156 386343.3083 650.3428
421293.4156 386343.3083 650.4952
421293.4156 386343.3083 650.6476
421293.4156 386343.3083 650.8
421293.4156 386343.3083 650.9524
421293.4156 386343.3083 651.1048
421293.4156 386343.3083 651.2572
421293.4156 386343.3083 651.4096
421293.4156 386343.3083 651.562