# Interactive animated 3D visualization of movement and orientation data?

I am working on object orientation and movement tracking and I need a way to visualize that data. For this I would like to graph the 3-axes arrows of the object frame in some kind of interactive 3D plot that would represent the world frame. Ideally, that visualization would be:

• interactive: so I can use the mouse to rotate, zoom, move the 3D view
• animated: so I can watch how the 3-axes arrows move over time, optionally leaving a trace over regular intervals

Ideally it could look somewhat like this (which I think is from Matlab):

Could anyone point me to plotting/visualization packages which may be best suited for that job, especially if the visualization should happen in a jupyter notebook or in jupyter lab?

Alternately, does anyone know free open source visualization software (which should run on Linux) which could be used for this separate from Python, e.g. by Python creating the necessary file and then the software doing the interactive visualization?

Hi,

consider the `plotly` graphing libraries:

Plotly Python Graphing Library

If you scroll a bit towards the bottom, there are options for 3D plotting. If you scroll even further,

Here is a simple example:

``````import plotly.graph_objs as go
import numpy as np

z = np.linspace(0, 10, 50)
x = np.cos(z)
y = np.sin(z)
trace = go.Scatter3d(x = x, y = y, z = z, mode = 'markers')
marker = dict(size = 12, color = z, colorscale = 'Viridis')

layout = go.Layout(title = '3D Scatter plot')
fig = go.Figure(data = [trace], layout = layout)
fig.show()

``````

Thank you, this is a nice library for visualizing 3D scatter plots, but how would one visualize the axis-crosses in order to indicate 3D orientation?
Here is an example that is perhaps better illustrating what is needed:

As you can see, this shows the orientation at different point by drawing the 3 unit vectors of the object frame coordinate system (red, green, blue). In other words, for each time step, I can see where the object is located in 3D space but also which orientation the object has.
Is it possible to draw such an object with an arbitrary orientation into the 3D coordinate system with Plotly?
Of not, what other library would allow me to do that?

Hi,

for plotting 3D graphs with vectors using the `plotly` package library, reference the following webpage:

Goodluck.

You should also check Mayavi. Perhaps looking through their gallery of examples you can find something alike to what you want.

Thank you, those cones are sure useful for indicating such flow directions, but for orientation I would need the kind of â€śaxisâ€ť object (with 3 orthogonal line segments) as shown in the example image and after looking around in Plotly, it do not think they have a trace type for that. I could not even find a way to plot line segments so I could manually implement those â€śaxisâ€ť objects by having multiple traces. Not sure if I am missing something here, but to me it looks as if plotly would not be able to do this?

Thank you! I did not know of that tool, from a first glance it looks as if it should allow to manually draw those orientation axes into the 3D scene, I will have a closer look!

Like this:

``````import matplotlib.pyplot as plt

# Reference or starting point to create vectors
start = [0, 0, 0]

# Ending points of vectors
u = [7, 3, 1]
v = [1, 5, 4]
q = [3, -8, 4]

fig = plt.figure()
ax = plt.axes(projection = '3d')

# Define axis limits
ax.set_xlim([-1, 10])
ax.set_ylim([-10, 10])
ax.set_zlim([0, 10])

# Create vectors to plot
ax.quiver(start[0], start[1], start[2], u[0], u[1], u[2], color = 'g')
ax.quiver(start[0], start[1], start[2], v[0], v[1], v[2])
ax.quiver(start[0], start[1], start[2], q[0], q[1], q[2], color = 'r')

ax.view_init(10, 10)

plt.show()

``````

1 Like