pyvista.AxesAssembly#

class AxesAssembly(
*,
x_label: str | None = None,
y_label: str | None = None,
z_label: str | None = None,
labels: Sequence[str] | None = None,
label_color: ColorLike = 'black',
show_labels: bool = True,
label_position: float | VectorLike[float] | None = None,
label_size: int = 50,
x_color: ColorLike | Sequence[ColorLike] | None = None,
y_color: ColorLike | Sequence[ColorLike] | None = None,
z_color: ColorLike | Sequence[ColorLike] | None = None,
position: VectorLike[float] = (0.0, 0.0, 0.0),
orientation: VectorLike[float] = (0.0, 0.0, 0.0),
origin: VectorLike[float] = (0.0, 0.0, 0.0),
scale: VectorLike[float] = (1.0, 1.0, 1.0),
user_matrix: MatrixLike[float] | None = None,
**kwargs: Unpack[_AxesGeometryKwargs],
)[source]#

Assembly of arrow-style axes parts.

The axes may be used as a widget or added to a scene.

Parameters:
x_labelstr, default: ‘X’

Text label for the x-axis. Alternatively, set the label with labels.

y_labelstr, default: ‘Y’

Text label for the y-axis. Alternatively, set the label with labels.

z_labelstr, default: ‘Z’

Text label for the z-axis. Alternatively, set the label with labels.

labelsSequence[str], optional,

Text labels for the axes. This is an alternative parameter to using x_label, y_label, and z_label separately.

label_colorColorLike, default: ‘black’

Color of the text labels.

show_labelsbool, default: True

Show or hide the text labels.

label_positionfloat | VectorLike[float], optional

Position of the text labels along each axis. By default, the labels are positioned at the ends of the shafts.

label_sizeint, default: 50

Size of the text labels.

x_colorColorLike | Sequence[ColorLike], optional

Color of the x-axis shaft and tip.

y_colorColorLike | Sequence[ColorLike], optional

Color of the y-axis shaft and tip.

z_colorColorLike | Sequence[ColorLike], optional

Color of the z-axis shaft and tip.

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

Position of the axes in space.

orientationVectorLike[float], default: (0, 0, 0)

Orientation angles of the axes which define rotations about the world’s x-y-z axes. The angles are specified in degrees and in x-y-z order. However, the actual rotations are applied in the around the y-axis first, then the x-axis, and finally the z-axis.

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

Origin of the axes. This is the point about which all rotations take place. The rotations are defined by the orientation.

scaleVectorLike[float], default: (1.0, 1.0, 1.0)

Scaling factor applied to the axes.

user_matrixMatrixLike[float], optional

A 4x4 transformation matrix applied to the axes. Defaults to the identity matrix. The user matrix is the last transformation applied to the actor.

**kwargs

Keyword arguments passed to pyvista.AxesGeometrySource.

Examples

Add axes to a plot.

>>> import pyvista as pv
>>> axes = pv.AxesAssembly()
>>> pl = pv.Plotter()
>>> _ = pl.add_actor(axes)
>>> pl.show()
../../../_images/pyvista-AxesAssembly-1_00_00.png

Customize the axes colors. Set each axis to a single color, or set the colors of each shaft and tip separately with two colors.

>>> axes.x_color = ['cyan', 'blue']
>>> axes.y_color = ['magenta', 'red']
>>> axes.z_color = 'yellow'

Customize the label color too.

>>> axes.label_color = 'brown'
>>> pl = pv.Plotter()
>>> _ = pl.add_actor(axes)
>>> pl.show()
../../../_images/pyvista-AxesAssembly-1_01_00.png

Create axes with custom geometry. Use pyramid shafts and hemisphere tips and modify the lengths.

>>> axes = pv.AxesAssembly(
...     shaft_type='pyramid',
...     tip_type='hemisphere',
...     tip_length=0.1,
...     shaft_length=(0.5, 1.0, 1.5),
... )
>>> pl = pv.Plotter()
>>> _ = pl.add_actor(axes)
>>> pl.show()
../../../_images/pyvista-AxesAssembly-1_02_00.png

Position and orient the axes in space.

>>> axes = pv.AxesAssembly(
...     position=(1.0, 2.0, 3.0), orientation=(10, 20, 30)
... )
>>> pl = pv.Plotter()
>>> _ = pl.add_actor(axes)
>>> pl.show()
../../../_images/pyvista-AxesAssembly-1_03_00.png

Add the axes as a custom orientation widget with add_orientation_widget():

>>> import pyvista as pv
>>> axes = pv.AxesAssembly(symmetric_bounds=True)
>>> pl = pv.Plotter()
>>> _ = pl.add_mesh(pv.Cone())
>>> _ = pl.add_orientation_widget(
...     axes,
...     viewport=(0, 0, 0.5, 0.5),
... )
>>> pl.show()
../../../_images/pyvista-AxesAssembly-1_04_00.png

Methods

AxesAssembly.get_actor_prop(name)

Get Property attributes for the axes shaft and/or tip actors.

AxesAssembly.set_actor_prop(name, value[, ...])

Set Property attributes for the axes shaft and/or tip actors.

Attributes

AxesAssembly.bounds

Return the bounds of the axes.

AxesAssembly.center

Return the center of the axes.

AxesAssembly.label_color

Color of the text labels.

AxesAssembly.label_position

Position of the text label along each axis.

AxesAssembly.label_size

Size of the text labels.

AxesAssembly.labels

Return or set the axes labels.

AxesAssembly.length

Return the length of the axes.

AxesAssembly.orientation

Return or set the axes orientation angles.

AxesAssembly.origin

Return or set the origin of the axes.

AxesAssembly.position

Return or set the position of the axes.

AxesAssembly.scale

Return or set the scaling factor applied to the axes.

AxesAssembly.show_labels

Show or hide the text labels for the axes.

AxesAssembly.user_matrix

Return or set the user matrix.

AxesAssembly.x_color

Color of the x-axis shaft and tip.

AxesAssembly.x_label

Text label for the x-axis.

AxesAssembly.y_color

Color of the y-axis shaft and tip.

AxesAssembly.y_label

Text label for the y-axis.

AxesAssembly.z_color

Color of the z-axis shaft and tip.

AxesAssembly.z_label

Text label for the z-axis.