pyvista.Plotter.add_text

pyvista.Plotter.add_text#

Plotter.add_text(
text: str,
position: Literal['lower_left', 'lower_right', 'upper_left', 'upper_right', 'lower_edge', 'upper_edge', 'right_edge', 'left_edge'] | Sequence[float] | None = 'upper_left',
font_size: int | None = 18,
color: ColorLike | None = None,
font: FontFamilyOptions | None = None,
shadow: bool = False,
name: str | None = None,
viewport: bool = False,
orientation: float = 0.0,
font_file: str | None = None,
*,
render: bool = True,
) CornerAnnotation | Text[ソース]#

既定では,印刷オブジェクトの左上コーナーに文字を追加します.

パラメータ:
textstr

レンダリングを追加するテキスト.

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

タイトルフォントのサイズを設定します.

colorColorLike, optional

文字列,RGBリスト,または16進カラー文字列.例:

  • color='white'

  • color='w'

  • color=[1.0, 1.0, 1.0]

  • color='#FFFFFF'

デフォルトは pyvista.global_theme.font.color です.

fontstr, default: 'arial'

フォント名は 'courier', `` times', ``'arial' のいずれかです.これは font_file が設定されている場合は無視されます.

shadowbool, default: False

テキストに黒い影を追加します.

namestr, optional

簡単に更新できるように,追加したアクターの名前.この名前のアクターがレンダリングウィンドウに既に存在する場合は,新しいアクターに置き換えられます.

viewportbool, default: False

True でpositionがfloatのタプルの場合,は正規化されたビューポート座標系(0.0から1.0までの値とHiDPIのサポート)を使用します.

orientationfloat, default: 0.0

テキストを反時計回りに回転させる度数の角度. テキストは,テキストの端または角にあるアンカーポイントを中心に回転されます. デフォルトは水平(0.0度)です.

font_filestr, default: None

フリータイプ可読フォントを含むローカルファイルへの絶対フ ァ イ ルパス.

renderbool, default: True

True のときに強制的にレンダーします.

戻り値:
CornerAnnotation | Text

プロットに追加されたテキストアクター.

プロッターの右上に青いテキストを追加します.

>>> import pyvista as pv
>>> pl = pv.Plotter()
>>> actor = pl.add_text(
...     'Sample Text',
...     position='upper_right',
...     color='blue',
...     shadow=True,
...     font_size=26,
... )
>>> pl.show()
../../../_images/pyvista-Plotter-add_text-1_00_00.png

テキストを追加し,カスタムフリータイプ可読フォントファイルを使用する.

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