Cube(center=(0.0, 0.0, 0.0), x_length=1.0, y_length=1.0, z_length=1.0, bounds=None, clean=True)[source]#

Create a cube.

It’s possible to specify either the center and side lengths or just the bounds of the cube. If bounds are given, all other arguments are ignored.

Changed in version 0.33.0: The cube is created using vtk.vtkCubeSource. For compatibility with pyvista.PlatonicSolid(), face indices are also added as cell data. For full compatibility with PlatonicSolid(), one has to use x_length = y_length = z_length = 2 * radius / 3**0.5. The cube points are also cleaned by default now, leaving only the 8 corners and a watertight (manifold) mesh.

centersequence[float], default: (0.0, 0.0, 0.0)

Center in [x, y, z].

x_lengthfloat, default: 1.0

Length of the cube in the x-direction.

y_lengthfloat, default: 1.0

Length of the cube in the y-direction.

z_lengthfloat, default: 1.0

Length of the cube in the z-direction.

boundssequence[float], optional

Specify the bounding box of the cube. If given, all other size arguments are ignored. (xMin, xMax, yMin, yMax, zMin, zMax).

cleanbool, default: True

Whether to clean the raw points of the mesh, making the cube manifold. Note that this will degrade the texture coordinates that come with the mesh, so if you plan to map a texture on the cube, consider setting this to False.

New in version 0.33.0.


Mesh of the cube.


Create a default cube.

>>> import pyvista as pv
>>> mesh = pv.Cube()
>>> mesh.plot(show_edges=True, line_width=5)