Getting camera view data for 3d plots

Hi folks,

I know there is a way to set the camera angle of a 3D scatter plot. I was just wondering if it possible to get the information of the camera angle (after plotting) when the graph has been rotated manually (eg. by the mouse)
?

Thanks :wink:

Edit: Sorry, I could have checked just a bit longer since I found kind of an answer:

fig.layout.scene.camera

Hi @Alexboiboi,

Yeah, if you display the figure using a FigureWidget (https://plot.ly/python/figurewidget/) in the Jupyter Notebook then you can access properties to lookup the current values of properties that are chosen by ploty.js as defaults, and properties that are modified interactively.

-Jon

1 Like

Hi! FigureWidget is not supported in frames. What could be a walkaround?

Resurrecting an old threat. I have a similar question. Iโ€™m setting up a 3d scatter plot using these initial camera properties:
fig.update_layout(scene_camera=dict(
eye=dict(x=1.2, y=1.2, z=0.6),
center=dict(x=0, y=0, z=0),
up=dict(x=0, y=0, z=1)

I then use the controls to adjust the figure and I expected these would adjust as I did that, but when I attempt to retrieve them I still get the original values. Iโ€™d like to be able to adjust the figure, collect the resulting values, then use those as the initialization properties, but I canโ€™t find the new properties. I could get there manually, but thatโ€™s a lot of adjust, run, adjust and doesnโ€™t take advantage of the ability to manipulate the image.

Is there a way to get the current updated properties?

HI @TSchip welcome to the forums.

I think that is due to how plotly works. Some things happen internally in the browser without being โ€œreflectedโ€ in python.

If you are open to use dash, I think you could grab the new camera position via a clientside callback or even a regular callback via the restyleData or relayoutData, Iโ€™m not sure right now, which of the two.

Thanks. Right now it is in a Jupyter notebook project Iโ€™m doing for my AI and ML program. I was wanting to try plotly here and the ability to rotate the graph is nice, but I may have to fall back to matplotlib for this one due to ease of including it in my submission.