Image.text#
- ImageToolsManager.text(text: str, x: float = 0.85, y: float = 0.85, ax: Axes | int | None = None, c: str = 'k', **kwargs: Unpack[TextKwargs]) 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.
- - bbox: str | None, default None
The bounding box for the text.
- - bottom: float, default varies
The bottom limit of the axis / axes set. For the figure layout it is the space from the bottom border to the plot (default 0.1); for an inset zoom it is the bottom position of the inset (default 0.6 + height).
- - c: str, default ‘k’
The text color.
- - figsize: list[float], default varies
Sets the figure size. The default is [6*sqrt(ncol), 5*sqrt(nrow)], computed from the number of rows and columns (or [8,5] for a single plot).
- - fontsize: float, default 17.0
Sets the fontsize for all the axis components.
- - horalign: str, default ‘left’
The horizontal alignment. Possible values are ‘left’, ‘center’, ‘right’.
- - hratio: [float], default [1.0]
Ratio between the rows of the plot. The default is that every plot row has the same height.
- - hspace: [float], default []
The space between plot rows (in figure units). If not enough or too many spaces are considered, the program will remove the excess and fill the lacks with [0.1].
- - left: float, default varies
The left limit of the axis / axes set. For the figure layout it is the space from the left border to the plot (default 0.125); for an inset zoom it is the left position of the inset (default 0.6).
- - ncol: int, default 1
The number of columns of subplots.
- - nrow: int, default 1
The number of rows of subplots.
- - proj: str, default None
Custom projection for the plot (e.g. 3D). Recommended only if needed. WARNING: pyPLUTO does not support 3D plotting for now, only 3D axes. The 3D plot feature will be available in future releases.
- - right: float, default varies
The right limit of the axis / axes set. For the figure layout it is the space from the right border to the plot (default 0.9); for an inset zoom it is the right position of the inset (default left + 0.15).
- - sharex: bool | str | Matplotlib axis, default False
Enables/disables the sharing of the x-axis between the subplots.
- - sharey: bool | str | Matplotlib axis, default False
Enables/disables the sharing of the y-axis between the subplots.
- - suptitle: str, default None
Creates a figure title over all the subplots.
- - 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.
- - tight: bool, default True
Enables/disables tight layout options for the figure. In case of a highly customized plot (e.g. ratios or space between rows and columns) the option is set by default to False since that option would not be available for standard matplotlib functions.
- - top: float, default varies
The top limit of the axis / axes set. For the figure layout it is the space from the top border to the plot (default 0.9); for an inset zoom it is the top position of the inset (default bottom + height).
- - 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.
- - wratio: [float], default [1.0]
Ratio between the columns of the plot. The default is that every plot column has the same width.
- - wspace: [float], default []
The space between plot columns (in figure units). If not enough or too many spaces are considered, the program will remove the excess and fill the lacks with [0.1].
- - 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")