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,
既定では,印刷オブジェクトの左上コーナーに文字を追加します.
- パラメータ:
- text
str レンダリングを追加するテキスト.
- position
str| 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_size
float, default: 18 タイトルフォントのサイズを設定します.
- color
ColorLike,optional 文字列,RGBリスト,または16進カラー文字列.例:
color='white'color='w'color=[1.0, 1.0, 1.0]color='#FFFFFF'
デフォルトは
pyvista.global_theme.font.colorです.- font
str, default: 'arial' フォント名は
'courier', `` times', ``'arial'のいずれかです.これは font_file が設定されている場合は無視されます.- shadowbool, default:
False テキストに黒い影を追加します.
- name
str,optional 簡単に更新できるように,追加したアクターの名前.この名前のアクターがレンダリングウィンドウに既に存在する場合は,新しいアクターに置き換えられます.
- viewportbool, default:
False Trueでpositionがfloatのタプルの場合,は正規化されたビューポート座標系(0.0から1.0までの値とHiDPIのサポート)を使用します.- orientation
float, default: 0.0 テキストを反時計回りに回転させる度数の角度. テキストは,テキストの端または角にあるアンカーポイントを中心に回転されます. デフォルトは水平(0.0度)です.
- font_file
str, default:None フリータイプ可読フォントを含むローカルファイルへの絶対フ ァ イ ルパス.
- renderbool, default:
True Trueのときに強制的にレンダーします.
- text
- 戻り値:
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()
テキストを追加し,カスタムフリータイプ可読フォントファイルを使用する.
>>> pl = pv.Plotter() >>> actor = pl.add_text( ... 'Text', ... font_file='/home/user/Mplus2-Regular.ttf', ... )