Image.text#

ImageToolsManager.text(text: str, x: float = 0.85, y: float = 0.85, ax: Axes | int | None = None, check: bool = True, **kwargs: Any) None[source]#

Insert a text box inside the figure created with Image class.

Parameters:
- ax: axis object, default None

The axis where to insert the text box. If None, the last considered axis will be used.

- c: str, default ‘k’

Determines the text color.

- horalign: str, default ‘left’

The horizontal alignment. Possible values are ‘left’, ‘center’, ‘right’.

- text (not optional): str

The text that will appear on the text box

- textsize: float, default fontsize

Sets the text fontsize. The default value corresponds to the value of the actual fontsize in the figure.

- veralign: str, default ‘baseline’

The vertical alignment. Possible values are ‘baseline’, ‘bottom’, ‘center’, ‘center_baseline’, ‘top’.

- x: float, default 0.85

The horizontal starting position of the text box, in units of figure size.

- xycoords: str, default ‘fraction’

The coordinate system used. Possible values are ‘figure fraction’, which sets the position as a fraction of the axis (inside the axis lie values between 0 and 1), ‘points’, which sets the position in units of the x/y coordinate system, and ‘figure’, which sets the position as a fraction of the figure.

- y: float, default 0.85

The vertical starting position of the text box, in units of figure size.

—-
Returns:
  • None

Examples

  • Example #1: Insert text inside a specific axis

    >>> I.text("text", x=0.5, y=0.5, ax=ax)
    
  • Example #2: Insert text inside the last axis

    >>> I.text("text", x=0.5, y=0.5)
    
  • Example #3: Insert text inside the last axis with a specific fontsize

    >>> I.text("text", x=0.5, y=0.5, textsize=20)
    
  • Example #4: Insert text inside the last axis with a specific fontsize

    and a specific color

    >>> I.text("text", x=0.5, y=0.5, textsize=20, c="r")
    
  • Example #5: Insert text inside the last axis with a points position

    >>> I.text("text", x=0.5, y=0.5, xycoords="points")