add_text#
- Plotter.add_text(text, position='upper_left', font_size=18, color=None, font=None, shadow=False, name=None, viewport=False, *, render=True)#
Add text to plot object in the top left corner by default.
- Parameters
- text
str
The text to add the rendering.
- position
str
,tuple
(float
),optional
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_size
float
,optional
Sets the size of the title font. Defaults to 18.
- color
color_like
,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
.- font
str
,optional
Font name may be
'courier'
,'times'
, or'arial'
.- shadowbool,
optional
Adds a black shadow to the text. Defaults to
False
.- name
str
,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,
optional
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).- renderbool,
optional
Force a render when
True
(default).
- text
- Returns
vtk.vtkTextActor
Text actor added to plot.
Examples
>>> import pyvista >>> pl = pyvista.Plotter() >>> actor = pl.add_text('Sample Text', position='upper_right', color='blue', ... shadow=True, font_size=26) >>> pl.show()