pyvista.Camera.tight

Contents

pyvista.Camera.tight#

Camera.tight(
padding=0.0,
adjust_render_window: bool = True,
view='xy',
negative: bool = False,
)[source]#

Adjust the camera position so that the actors fill the entire renderer.

The camera view direction is reoriented to be normal to the view plane. When negative=False, The first letter of view refers to the axis that points to the right. The second letter of view refers to axis that points up. When negative=True, the first letter refers to the axis that points left. The up direction is unchanged.

Parallel projection is enabled when using this function.

Parameters:
paddingfloat, default: 0.0

Additional padding around the actor(s). This is effectively a zoom, where a value of 0.01 results in a zoom out of 1%.

adjust_render_windowbool, default: True

Adjust the size of the render window as to match the dimensions of the visible actors.

view{‘xy’, ‘yx’, ‘xz’, ‘zx’, ‘yz’, ‘zy’}, default: ‘xy’

Plane to which the view is oriented.

negativebool, default: False

Whether to view in opposite direction.

Notes

This resets the view direction to look at a plane with parallel projection.

Examples

Display the puppy image with a tight view.

>>> import pyvista as pv
>>> from pyvista import examples
>>> puppy = examples.download_puppy()
>>> pl = pv.Plotter(border=True, border_width=5)
>>> _ = pl.add_mesh(puppy, rgb=True)
>>> pl.camera.tight()
>>> pl.show()
../../../_images/pyvista-Camera-tight-1_00_00.png

Set the background to blue use a 5% padding around the image.

>>> pl = pv.Plotter()
>>> _ = pl.add_mesh(puppy, rgb=True)
>>> pl.background_color = 'b'
>>> pl.camera.tight(padding=0.05)
>>> pl.show()
../../../_images/pyvista-Camera-tight-1_01_00.png