How set the Initial plotting Zoom to view whole model

Hi everyone

Using the below code I have set the size of axis range and ratio and it works correctly. But when I plot the model the zoom of model is not correct in first view and I have to zoom out the model to see whole of it. What should I do till when I plot the model, initially the whole model completely can be seen?

``````        fig.update_layout(
scene = dict(
xaxis = dict(nticks=4, range=[xmin-0.05*abs(xmax-xmin),xmax+0.05*abs(xmax-xmin)],),
yaxis = dict(nticks=4, range=[ymin-0.05*abs(ymax-ymin),ymax+0.05*abs(ymax-ymin)],),
zaxis = dict(nticks=4, range=[zmin-0.05*abs(zmax-zmin),zmax+0.05*abs(zmax-zmin)],),),)
fig.update_layout(scene_aspectmode='manual',scene_aspectratio=dict(x=1,
y=(ymax-ymin)/(xmax-xmin),
z=(zmax-zmin)/(xmax-xmin)))
``````

@Bijan To display your model, completely, set
`scene_camera_eye=dict(x=a, y=a, z=1)`, where `a` is chosen by trial and error. The default value for `a` is 1.25, but you mai set it even greater than 2.

1 Like

is there any reference about βaβ? Because I have various figures I need the scale of βaβ instead of trial and error. seems thatβs a ratio but it is not clear ratio of what values.

@Bijan
If you print `help(go.layout.scene.Camera.eye)` it is displayed the following information:

``````Help on property:

Sets the (x,y,z) components of the 'eye' camera vector. This
vector determines the view point about the origin of this
scene.

The 'eye' property is an instance of Eye
that may be specified as:
- An instance of :class:`plotly.graph_objs.layout.scene.camera.Eye`
- A dict of string/value properties that will be passed
to the Eye constructor

Supported dict properties:

x

y

z

Returns
-------
plotly.graph_objs.layout.scene.camera.Eye
``````

But here https://plotly.com/python/reference/layout/scene/#layout-scene-camera is mentioned that the default values are x=1.25, y=1.25, z=1.25. Thatβs all. If your plot is not visible entirely, you must try different values for x, y, z.

1 Like

I have the same problem, but βtrial and errorβ is not an option because I am plotting many different graphs in a loop.

I already tried calculating the camera distance (in my case cam eye z) from the maximum of the x and y ranges and a fov of 45 deg (which i read somewhere is the built-in fov), but that does not work for some reason. is there no option to tell the graph to adjust the zoom / size / cam-dist automatically so that it is wholly contained in the pixel dimensions of my layout?