# Examples from pyvista.AxesAssembly
# ==================================

# 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()

# Scale the axes non-uniformly.
axes = pv.AxesAssembly(scale=(2.0, 6.0, 10.0))
pl = pv.Plotter()
_ = pl.add_actor(axes)
pl.show()

# Note how the non-uniform scaling distorts the axes such that the tips all have different
# lengths and the shafts are no longer cylindrical. Use the anti-distortion mode when
# scaling to avoid this.
axes.scale_mode = 'anti_distortion'
pl = pv.Plotter()
_ = pl.add_actor(axes)
pl.show()

# Add axes to the minimum extent of a mesh's bounds.
mesh = pv.ParametricEllipsoid(xradius=6, yradius=3, zradius=1)

scale = mesh.bounds_size
position = (mesh.bounds.x_min, mesh.bounds.y_min, mesh.bounds.z_min)
axes = pv.AxesAssembly(
    position=position, scale=scale, scale_mode='anti_distortion'
)

pl = pv.Plotter()
_ = pl.add_mesh(mesh)
_ = pl.add_actor(axes)
pl.view_xy()
pl.show()

# Add the axes as a custom orientation widget with
# `add_orientation_widget()`.
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()

# ----------------------------------------------------------------------
# Generated by sphinx-examples-as-code https://github.com/pyvista/sphinx-examples-as-code

