Note
Go to the end to download the full example code.
Create 3D Text#
Generate extruded text geometry with pyvista.Text3D().
import pyvista as pv
Create an extruded text mesh#
The text is standard PolyData and can be transformed and plotted like any other surface.
Compare flat and extruded text#
depth=0 produces flat glyphs; a positive depth extrudes them into 3D.
flat = pv.Text3D('PyVista', depth=0)
extruded = pv.Text3D('PyVista', depth=0.4)
pl = pv.Plotter(shape=(1, 2))
pl.subplot(0, 0)
pl.add_mesh(flat, color='royalblue')
pl.view_xy()
pl.subplot(0, 1)
pl.add_mesh(extruded, color='royalblue')
pl.view_xy()
pl.camera.azimuth = -25
pl.camera.elevation = 20
pl.camera.zoom(0.85)
pl.show()

Total running time of the script: (0 minutes 0.155 seconds)