✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🐇 Announcing Dash VTK for 3d simulation graphics. Check out the March webinar.

How to get/change current scene/camera in 3D plot - inside Jupyter notebook (Python)

Say I have run plotted this 3D surface in a Jupyter notebook in Python: https://plot.ly/python/3d-surface-plots/

Now I move it around a bit and then I would like to grab the camera position and other scene parameters.
So I can plot with this viewpoint.

But also I would like to grab them to be able to programmatically rotate/animate the 3D plot, ideally using IPython widgets (https://github.com/ipython/ipywidgets). For that I need a handler to the js object.
I can’t find it. When I look into the fig object, it still contains the initial values.
From this post (How do I get the camera rotation angles from the “eye”?) I understand the scene object is accessible in pure JS.

Has somebody managed to do that in the notebook ?
Any pointers ?

Thx

Hi there,
You can set the camera position programatically in your notebook with the parameters described here: https://plot.ly/python/3d-camera-controls/
We don’t have an example setting these via an ipython widget at the moment, though using those parameters would be a good place to start.

Indeed, your example shows how to position the camera programmatically.
But how do I do to get a handler of an existing 3d plot in a notebook, get the camera position, change it a bit, and update the plot ?
This is what I can’t do.
Is it possible ?

Thx

2 Likes

Did you figure this out? I have a similar question.