Plotter.add_text(text, position='upper_left', font_size=18, color=None, font=None, shadow=False, name=None, viewport=False, orientation=0.0, font_file=None, *, render=True)[source]#

Add text to plot object in the top left corner by default.


The text to add the rendering.

positionstr | sequence[float], default: “upper_left”

Position to place the bottom left corner of the text box. If tuple is used, the position of the text uses the pixel coordinate system (default). In this case, it returns a more general vtkOpenGLTextActor. If string name is used, it returns a vtkCornerAnnotation object normally used for fixed labels (like title or xlabel). Default is to find the top left corner of the rendering window and place text box up there. Available position: 'lower_left', 'lower_right', 'upper_left', 'upper_right', 'lower_edge', 'upper_edge', 'right_edge', and 'left_edge'.

font_sizefloat, default: 18

Sets the size of the title font.

colorColorLike, optional

Either a string, RGB list, or hex color string. For example:

  • color='white'

  • color='w'

  • color=[1.0, 1.0, 1.0]

  • color='#FFFFFF'

Defaults to pyvista.global_theme.font.color.

fontstr, default: ‘arial’

Font name may be 'courier', 'times', or 'arial'. This is ignored if the font_file is set.

shadowbool, default: False

Adds a black shadow to the text.

namestr, optional

The name for the added actor so that it can be easily updated. If an actor of this name already exists in the rendering window, it will be replaced by the new actor.

viewportbool, default: False

If True and position is a tuple of float, uses the normalized viewport coordinate system (values between 0.0 and 1.0 and support for HiDPI).

orientationfloat, default: 0.0

Angle orientation of text counterclockwise in degrees. The text is rotated around an anchor point that may be on the edge or corner of the text. The default is horizontal (0.0 degrees).

font_filestr, default: None

The absolute file path to a local file containing a freetype readable font.

renderbool, default: True

Force a render when True.


Text actor added to plot.


Add blue text to the upper right of the plotter.

>>> import pyvista as pv
>>> pl = pv.Plotter()
>>> actor = pl.add_text(
...     'Sample Text',
...     position='upper_right',
...     color='blue',
...     shadow=True,
...     font_size=26,
... )

Add text and use a custom freetype readable font file.

>>> pl = pv.Plotter()
>>> actor = pl.add_text(
...     'Text',
...     font_file='/home/user/Mplus2-Regular.ttf',
... )