mpl_toolkits.mplot3d.axes3d.Axes3D.text2D#

Axes3D.text2D(x, y, s, fontdict=None, **kwargs)[源代码]#

向坐标系中添加文本。

在数据坐标中的 x, y 位置向坐标轴添加文本 s,默认 horizontalalignmentleftverticalalignmentbaseline。参阅 文本对齐

参数:
x, y浮点数

放置文本的位置。默认情况下,这是数据坐标。可以使用 transform 参数更改坐标系。

s字符串

文本内容。

fontdictdict, 默认值: None

不建议使用

不建议使用 fontdict。参数应作为单独的关键字参数或使用字典解包 text(..., **fontdict) 传递。

一个用于覆盖默认文本属性的字典。如果 fontdict 为 None,则默认值由 rcParams 决定。

返回:
文本

创建的 Text 实例。

其他参数:
**kwargsText 属性。

其他杂项文本参数。

属性

描述

agg_filter

一个过滤函数,它接受一个 (m, n, 3) 浮点数组和一个 dpi 值,并返回一个 (m, n, 3) 数组以及图像左下角的两个偏移量

alpha

浮点数或 None

animated

布尔值

antialiased

布尔值

backgroundcolor

color

bbox

带有 patches.FancyBboxPatch 属性的字典

clip_box

未知

clip_on

未知

clip_path

未知

colorc

color

figure

FigureSubFigure

fontfamilyfamilyfontname

{字体名称, 'serif', 'sans-serif', 'cursive', 'fantasy', 'monospace'}

fontpropertiesfontfont_properties

font_manager.FontPropertiesstrpathlib.Path

fontsizesize

float 或 {'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large'}

fontstretchstretch

{0-1000 范围内的数值, 'ultra-condensed', 'extra-condensed', 'condensed', 'semi-condensed', 'normal', 'semi-expanded', 'expanded', 'extra-expanded', 'ultra-expanded'}

fontstylestyle

{'normal', 'italic', 'oblique'}

fontvariantvariant

{'normal', 'small-caps'}

fontweightweight

{0-1000 范围内的数值, 'ultralight', 'light', 'normal', 'regular', 'book', 'medium', 'roman', 'semibold', 'demibold', 'demi', 'bold', 'heavy', 'extra bold', 'black'}

gid

字符串

horizontalalignmentha

{'left', 'center', 'right'}

in_layout

布尔值

label

对象

linespacing

float (字体大小的倍数)

math_fontfamily

字符串

mouseover

布尔值

multialignmentma

{'left', 'right', 'center'}

parse_math

布尔值

path_effects

AbstractPathEffect 列表

picker

None 或 布尔值 或 浮点数 或 可调用对象

position

(浮点数, 浮点数)

rasterized

布尔值

rotation

float 或 {'vertical', 'horizontal'}

rotation_mode

{None, 'default', 'anchor'}

sketch_params

(scale: 浮点数, length: 浮点数, randomness: 浮点数)

snap

布尔值或 None

text

对象

transform

变换

transform_rotates_text

布尔值

url

字符串

usetex

布尔值,默认值:rcParams["text.usetex"] (默认为:False)

verticalalignmentva

{'baseline', 'bottom', 'center', 'center_baseline', 'top'}

visible

布尔值

wrap

布尔值

x

浮点数

y

浮点数

zorder

浮点数

示例

可以使用单独的关键字参数覆盖任何给定参数

>>> text(x, y, s, fontsize=12)

默认变换指定文本使用数据坐标,或者,您可以指定文本使用轴坐标((0, 0) 是左下角,(1, 1) 是右上角)。下面的示例将文本放置在坐标系的中心

>>> text(0.5, 0.5, 'matplotlib', horizontalalignment='center',
...      verticalalignment='center', transform=ax.transAxes)

您可以使用关键字 bbox 在文本实例周围添加一个矩形框(例如,设置背景颜色)。bbox 是一个包含 Rectangle 属性的字典。例如

>>> text(x, y, s, bbox=dict(facecolor='red', alpha=0.5))

使用 mpl_toolkits.mplot3d.axes3d.Axes3D.text2D 的示例#

三维文本注释

三维文本注释