Plotter.view_vector

Plotter.view_vector#

Plotter.view_vector(
vector: VectorLikeFloat,
viewup: VectorLikeFloat | None = None,
*,
render: bool = True,
bounds: VectorLikeFloat | None = None,
) → None[source]#

View the scene from the direction of the given vector.

The camera is placed along vector from the center of the scene and looks back toward it, so it looks in the direction opposite to vector.

Parameters:
vectorVectorLikeFloat

Vector pointing from the focal point to the camera position.

viewupVectorLikeFloat, optional

Sequence describing the view up of the camera.

renderbool, default: True

If the render window is being shown, trigger a render after setting the camera position.

boundsVectorLikeFloat, optional

Automatically set up the camera based on a specified bounding box (x_min, x_max, y_min, y_max, z_min, z_max).

Examples#

Download Python source code | Download Jupyter notebook

View a sphere from the positive x-axis. The camera looks in the negative x direction.

>>> import pyvista as pv
>>> pl = pv.Plotter()
>>> _ = pl.add_mesh(pv.Sphere())
>>> pl.view_vector([1, 0, 0])
>>> pl.camera.direction
(-1.0, 0.0, 0.0)

View a built-in mesh from the (1, 1, 1) direction. The camera is placed along this vector and looks back toward the center of the mesh, so the positive x, y and z axes all point toward the viewer.

>>> from pyvista import examples
>>> airplane = examples.load_airplane()
>>> pl = pv.Plotter()
>>> _ = pl.add_mesh(airplane)
>>> pl.view_vector([1, 1, 1])
>>> pl.show_axes()
>>> pl.show()
../../../_images/pyvista-Plotter-view_vector-5f89aeaac7e720c4_00_01.png