flexitext
Draw text with multiple formats.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
float |
The horizontal position to place the text. By default, this is in axes fraction coordinates. |
required |
y |
float |
The vertical position to place the text. By default, this is in axes fraction coordinates. |
required |
ha |
str |
Horizontal alignment. Must be one of |
'left' |
va |
str |
Horizontal alignment. Must be one of |
'center' |
ma |
str |
Alignment for multiline texts. The layout of the bounding box of all the lines is
determined by the |
'left' |
mva |
str |
Vertical alignment for text within multiline texts. Can be one of |
'baseline' |
xycoords |
str |
The coordinate system for |
'axes fraction' |
ax |
matplotlib.axes.Axes |
Matplotlib |
None |
Returns:
Type | Description |
---|---|
matplotlib.offsetbox.AnnotationBbox |
Source code in flexitext/flexitext.py
def flexitext(
x,
y,
s,
ha="left",
va="center",
ma="left",
mva="baseline",
xycoords="axes fraction",
ax=None,
):
"""Draw text with multiple formats.
Parameters
----------
x: float
The horizontal position to place the text. By default, this is in axes fraction
coordinates.
y: float
The vertical position to place the text. By default, this is in axes fraction
coordinates.
ha: str
Horizontal alignment. Must be one of `'center'`, `'right'`, or `'left'`.
va: str
Horizontal alignment. Must be one of `'center'`, `'top'`, or `'bottom'`.
ma: str
Alignment for multiline texts. The layout of the bounding box of all the lines is
determined by the `ha` and `va` properties. This property controls the alignment of the
text lines within that box.
mva: str
Vertical alignment for text within multiline texts. Can be one of `"top"`, `"bottom"`,
`"left"`, `"right"`, `"center"`, or `"baseline"`. Defaults to `"baseline"`.
xycoords: str
The coordinate system for `x` and `y`. Must be one of `'axes fraction'` or
`'figure fraction'`.
ax: matplotlib.axes.Axes
Matplotlib `Axes`. The default value means the `Axes` is obtained with `plt.gca()`
Returns
-------
annotation_box: matplotlib.offsetbox.AnnotationBbox
"""
return FlexiText(*make_texts(s)).plot(x, y, ha, va, ma, mva, xycoords, ax)