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],
Assembly of arrow-style axes parts.
The axes may be used as a widget or added to a scene.
- Parameters:
- x_label
str
, default: ‘X’ Text label for the x-axis. Alternatively, set the label with
labels
.- y_label
str
, default: ‘Y’ Text label for the y-axis. Alternatively, set the label with
labels
.- z_label
str
, default: ‘Z’ Text label for the z-axis. Alternatively, set the label with
labels
.- labels
Sequence
[str
], optional, Text labels for the axes. This is an alternative parameter to using
x_label
,y_label
, andz_label
separately.- label_color
ColorLike
, default: ‘black’ Color of the text labels.
- show_labelsbool, default:
True
Show or hide the text labels.
- label_position
float
|VectorLike
[float
],optional
Position of the text labels along each axis. By default, the labels are positioned at the ends of the shafts.
- label_size
int
, default: 50 Size of the text labels.
- x_color
ColorLike
|Sequence
[ColorLike
],optional
Color of the x-axis shaft and tip.
- y_color
ColorLike
|Sequence
[ColorLike
],optional
Color of the y-axis shaft and tip.
- z_color
ColorLike
|Sequence
[ColorLike
],optional
Color of the z-axis shaft and tip.
- position
VectorLike
[float
], default: (0.0, 0.0, 0.0) Position of the axes in space.
- orientation
VectorLike
[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.
- origin
VectorLike
[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
.- scale
VectorLike
[float
], default: (1.0, 1.0, 1.0) Scaling factor applied to the axes.
- user_matrix
MatrixLike
[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
.
- x_label
Examples
Add axes to a plot.
>>> import pyvista as pv >>> axes = pv.AxesAssembly() >>> pl = pv.Plotter() >>> _ = pl.add_actor(axes) >>> pl.show()
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()
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()
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()
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()
Methods
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
Return the bounds of the axes.
Return the center of the axes.
Color of the text labels.
Position of the text label along each axis.
Size of the text labels.
Return or set the axes labels.
Return the length of the axes.
Return or set the axes orientation angles.
Return or set the origin of the axes.
Return or set the position of the axes.
Return or set the scaling factor applied to the axes.
Show or hide the text labels for the axes.
Return or set the user matrix.
Color of the x-axis shaft and tip.
Text label for the x-axis.
Color of the y-axis shaft and tip.
Text label for the y-axis.
Color of the z-axis shaft and tip.
Text label for the z-axis.