graphinglib.Text#
- class graphinglib.Text(x: float, y: float, text: str, color: str | Inherit = Inherit, font_size: float | Literal['same as figure'] = 'same as figure', alpha: float | Inherit = Inherit, h_align: str | Inherit = Inherit, v_align: str | Inherit = Inherit, rotation: float = 0.0, highlight_color: str | None = None, highlight_alpha: float = 1.0, highlight_padding: float = 0.1)[source]#
This class allows text to be plotted.
It is also possible to attach an arrow to the
Textwith the methodattach_arrow()to point at something of interest in the plot.- Parameters:
- x, yfloat
The x and y coordinates at which to plot the
Text.- textstr
The text to be plotted.
- colorstr
Color of the text. Default depends on the
figure_styleconfiguration.- font_sizefloat
Font size of the text. Typical range is
8to20. Default depends on thefigure_styleconfiguration.- alphafloat
Opacity of the text. Range is
0(transparent) to1(opaque). Default depends on thefigure_styleconfiguration.- h_align, v_alignstr
Horizontal and vertical alignment of the text. Horizontal alignment values include
"left","center", and"right". Vertical alignment values include"bottom","baseline","center","center_baseline", and"top". Default depends on thefigure_styleconfiguration.- rotationfloat
Rotation angle of the text in degrees. Defaults to 0.
- highlight_colorstr, optional
Color of the background highlight box behind the text. If specified, a box will be drawn behind the text. Default is
None(no highlight).- highlight_alphafloat, optional
Opacity of the highlight box. Range is
0(transparent) to1(opaque). Defaults to 1.0.- highlight_paddingfloat, optional
Padding around the text for the highlight box. A value of 0 means no padding. Defaults to 0.1.
Notes
Color parameters accept Matplotlib color formats: named colors (
"blue"), short color strings ("b"), hex strings ("#0000ff"), grayscale strings ("0.5"), and RGB/RGBA tuples with values between0and1((0, 0, 1)or(0, 0, 1, 0.5)).Methods
__init__(x, y, text[, color, font_size, ...])This class allows text to be plotted.
add_arrow(points_to[, width, shrink, ...])Adds an arrow pointing from the
Textto a specified point.copy()Returns a deep copy of the
Textobject.copy_with(**kwargs)Returns a deep copy of the Plottable with specified attributes overridden.