Hello all, I am trying to use Plotly in Python
to create an animated (vector) cone field
where the color of each cone is specified
independently and not all vectors are persistent in time.
Allow me to elaborate.
For example, if I have a file āsampleVectors.csvā,
as follows:
time,x,y,z,u,v,w,temperature
0, 0, 0, 0, 1.1, 1.6, 1.4, 15.5
0, 1.1, 1.2, 1.3, 2.2, 2.4, 2.6, 13.0
0, 0.5, 0.7, 0.5, 1.5, 0.5, 1.0, 13.0
1, 1.0, 0.8, 1.2, 1.0, 1.2, 1.4, 12.5
2, 2.1, 2.3, 1.8, 2.2, 2.4, 2.6, 14.0
2, 1.8, 1.9, 2.0, 2.7, 2.3, 2.5, 14.2
I know I can use āscatter_3dā from āplotly.expressā
to generate an animation similar to what I aim
but with spheres (please, see code below):
import plotly.express as px
import pandas as pd
import numpy as np
df = pd.read_csv('sampleVectors.csv')
fig = px.scatter_3d(df, x='x', y='y', z='z',
# u='u', v='v', w='w', # <---- direction
animation_frame='time',
color='temperature',
size = np.linalg.norm(df[['u','v','w']].values,axis=1),#norm of velocity
size_max=50,
opacity=0.7,
color_continuous_scale=px.colors.sequential.Blues
)
fig.update_layout(
scene = dict(
xaxis = dict(nticks=4, range=[0,3]),
yaxis = dict(nticks=4, range=[0,3]),
zaxis = dict(nticks=4, range=[0,3]),
aspectmode='manual',
aspectratio=dict(x=1, y=1, z=1))
)
fig.show() #working offline
But I would ideally like (in order of importance):
- The markers to be cones with
the direction of the cones given
by āuā,āvā,āwā. - The color to be specified for each cone via ātemperatureā.
I have not been able to find information
for āConeā from āplotly.graph_objectsā
either on how to make an animation or
on how to specify the color of each cone
independently. Even achieving either one
of those two items would be very helpful to me.
Thank you very much in advance.