File size: 2,560 Bytes
a67ae61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# Preface {.unnumbered}



```{python}
# | echo: false
#| code-fold: true
import numpy as np
import plotly.io as pio
pio.renderers.default = "plotly_mimetype+notebook_connected"
import plotly.graph_objects as go # to combine figures

# load data from the numpy npz file
data = np.load('Data/6_Html_Data/0_Viz/plt_Dat_16.78.npz')

# extraxt the data - load it
x_Traj =  data["x"]
y_Traj =  data["y"]
z_Traj =  data["z"]
x_Cone = data["x_Cone"]
y_Cone = data["y_Cone"]
z_Cone = data["z_Cone"]
u_Cone = data["u_Cone"]
v_Cone = data["v_Cone"]
w_Cone = data["w_Cone"]

# The trajectory
fig = go.Figure(data=[go.Scatter3d(
                        x= x_Traj,
                        y= y_Traj,
                        z= z_Traj,
                        name = "Trajectory",
                        showlegend = False,
                    )])


fig.update_traces(marker_size = 2,
                  mode = "lines",
                  marker_color ="green")


# Cones
fig_Cones = go.Figure(data=go.Cone(  x = x_Cone ,
                                y = y_Cone ,
                                z = z_Cone ,
                                u = u_Cone ,
                                v = v_Cone ,
                                w = w_Cone ,
                                name = "Direction",
                                showlegend = False,

                                )
                    )


# hiding color-bar
fig_Cones.update_traces(showscale=False)

# combine cone and trajectory
fig.add_traces(data = fig_Cones.data)


# style the figure
fig.update_layout(
    # plotlyexpress 3d axes:
    scene = dict(
        xaxis = dict(
            showbackground = False,
            showticklabels  = False,
            title='',
            showgrid = False,
            zeroline = False,),
        yaxis = dict(
            showbackground = False,
            showticklabels  = False,
            title='',
            showgrid = False,
            zeroline = False,),
        zaxis = dict(
            showbackground = False,
            showticklabels  = False,
            title='',
            showgrid = False,
            zeroline = False,
        ),
            ),
    # template= 'plotly_dark'
    # template= 'plotly'
    paper_bgcolor='rgba(0,0,0,0)',
    plot_bgcolor='rgba(0,0,0,0)',
    modebar = dict(bgcolor='rgba(0, 0, 0, 0)'),
    margin=dict(
        l=0,
        r=0,
        b=0,
        t=0,
        pad=0
                ),

    scene_camera_eye=dict(x=0, 
                          y=1,
                          z=0),
)

fig.show()
```