mpl_toolkits.mplot3d.art3d.Text3D#

class mpl_toolkits.mplot3d.art3d.Text3D(x=0, y=0, z=0, text='', zdir='z', **kwargs)[源代码][源代码]#

基类:Text

具有3D位置和方向的文本对象。

参数:
x, y, z浮动

文本的位置。

文本str

要显示的文本字符串。

zdir{'x', 'y', 'z', None, 3-tuple}

文本的方向。关于值的描述,请参见 get_dir_vector

其他参数:
**kwargs

所有其他参数都会传递给 Text

x, y 位置创建一个带有字符串 textText 实例。

文本相对于锚点 (x, y) 根据 ``horizontalalignment``(默认:'left')和 ``verticalalignment``(默认:'baseline')进行对齐。另请参阅 文本对齐

虽然 Text 接受 'label' 关键字参数,但默认情况下它不会添加到图例的句柄中。

有效的关键字参数是:

属性

描述

agg_filter

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

alpha

标量或无

animated

布尔值

抗锯齿

布尔值

backgroundcolor

color

bbox

带有 patches.FancyBboxPatch 属性的字典

clip_box

未知

clip_on

未知

clip_path

未知

颜色 或 c

color

figure

FigureSubFigure

fontfamily 或 family 或 fontname

{FONTNAME, 'serif', 'sans-serif', 'cursive', 'fantasy', 'monospace'}

fontproperties 或 font 或 font_properties

font_manager.FontPropertiesstrpathlib.Path

fontsize 或 size

浮点数或 {'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large'}

fontstretch 或 stretch

{一个数值范围在0-1000之间, '超压缩', '特压缩', '压缩', '半压缩', '正常', '半扩展', '扩展', '特扩展', '超扩展'}

fontstyle 或样式

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

fontvariant 或 variant

{'normal', 'small-caps'}

fontweight 或 weight

{一个数值范围在0-1000,'超轻','轻','正常','常规','书','中等','罗马','半粗','半粗','半','粗','重','特粗','黑'}

gid

str

horizontalalignment 或 ha

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

in_layout

布尔值

标签

对象

行间距

浮动(字体大小的倍数)

math_fontfamily

str

鼠标悬停

布尔值

multialignment 或 ma

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

parse_math

布尔值

path_effects

AbstractPathEffect 的列表

picker

None 或 bool 或 float 或 callable

位置

(浮点数, 浮点数)

光栅化

布尔值

旋转

浮点数 或 {'垂直', '水平'}

rotation_mode

{None, 'default', 'anchor'}

sketch_params

(scale: float, length: float, randomness: float)

snap

布尔值或无

文本

对象

transform

Transform

transform_rotates_text

布尔值

url

str

usetex

bool, 默认值: rcParams["text.usetex"] (default: False)

垂直对齐 或 va

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

可见

布尔值

wrap

布尔值

x

浮动

y

浮动

zorder

浮动

draw(renderer)[源代码][源代码]#

使用给定的渲染器绘制艺术家(及其子项)。

如果艺术家不可见(Artist.get_visible 返回 False),则此操作无效。

参数:
渲染器 : RendererBase 子类。RendererBase 子类。

注释

此方法在 Artist 子类中被重写。

get_position_3d()[源代码][源代码]#

返回文本的 (x, y, z) 位置。

get_tightbbox(renderer=None)[源代码][源代码]#

类似于 Artist.get_window_extent,但包括任何裁剪。

参数:
渲染器 : RendererBase 子类, 可选RendererBase 子类,可选

用于绘制图形的渲染器(即 fig.canvas.get_renderer()

返回:
Bbox 或 None

包围的边界框(在图像像素坐标中)。如果裁剪结果没有交集,则返回 None。

set(*, agg_filter=<UNSET>, alpha=<UNSET>, animated=<UNSET>, antialiased=<UNSET>, backgroundcolor=<UNSET>, bbox=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, color=<UNSET>, fontfamily=<UNSET>, fontproperties=<UNSET>, fontsize=<UNSET>, fontstretch=<UNSET>, fontstyle=<UNSET>, fontvariant=<UNSET>, fontweight=<UNSET>, gid=<UNSET>, horizontalalignment=<UNSET>, in_layout=<UNSET>, label=<UNSET>, linespacing=<UNSET>, math_fontfamily=<UNSET>, mouseover=<UNSET>, multialignment=<UNSET>, parse_math=<UNSET>, path_effects=<UNSET>, picker=<UNSET>, position=<UNSET>, position_3d=<UNSET>, rasterized=<UNSET>, rotation=<UNSET>, rotation_mode=<UNSET>, sketch_params=<UNSET>, snap=<UNSET>, text=<UNSET>, transform=<UNSET>, transform_rotates_text=<UNSET>, url=<UNSET>, usetex=<UNSET>, verticalalignment=<UNSET>, visible=<UNSET>, wrap=<UNSET>, x=<UNSET>, y=<UNSET>, z=<UNSET>, zorder=<UNSET>)[源代码]#

一次性设置多个属性。

支持的属性是

属性

描述

3d_properties

浮动

agg_filter

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

alpha

标量或无

animated

布尔值

抗锯齿

布尔值

backgroundcolor

color

bbox

带有 patches.FancyBboxPatch 属性的字典

clip_box

BboxBase 或 None

clip_on

布尔值

clip_path

补丁或(路径,变换)或无

颜色 或 c

color

figure

FigureSubFigure

fontfamily 或 family 或 fontname

{FONTNAME, 'serif', 'sans-serif', 'cursive', 'fantasy', 'monospace'}

fontproperties 或 font 或 font_properties

font_manager.FontPropertiesstrpathlib.Path

fontsize 或 size

浮点数或 {'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large'}

fontstretch 或 stretch

{一个数值范围在0-1000之间, '超压缩', '特压缩', '压缩', '半压缩', '正常', '半扩展', '扩展', '特扩展', '超扩展'}

fontstyle 或样式

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

fontvariant 或 variant

{'normal', 'small-caps'}

fontweight 或 weight

{一个数值范围在0-1000,'超轻','轻','正常','常规','书','中等','罗马','半粗','半粗','半','粗','重','特粗','黑'}

gid

str

horizontalalignment 或 ha

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

in_layout

布尔值

标签

对象

行间距

浮动(字体大小的倍数)

math_fontfamily

str

鼠标悬停

布尔值

multialignment 或 ma

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

parse_math

布尔值

path_effects

AbstractPathEffect 的列表

picker

None 或 bool 或 float 或 callable

位置

(浮点数, 浮点数)

position_3d

(浮点数, 浮点数, 浮点数)

光栅化

布尔值

旋转

浮点数 或 {'垂直', '水平'}

rotation_mode

{None, 'default', 'anchor'}

sketch_params

(scale: float, length: float, randomness: float)

snap

布尔值或无

文本

对象

transform

Transform

transform_rotates_text

布尔值

url

str

usetex

bool, 默认值: rcParams["text.usetex"] (default: False)

垂直对齐 或 va

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

可见

布尔值

wrap

布尔值

x

浮动

y

浮动

z

浮动

zorder

浮动

set_3d_properties(z=0, zdir='z')[源代码][源代码]#

设置文本的 z 位置和方向。

参数:
z浮动

三维空间中的z轴位置。

zdir{'x', 'y', 'z', 3-tuple}

文本的方向。默认值:'z'。关于值的描述,请参见 get_dir_vector

set_position_3d(xyz, zdir=None)[源代码][源代码]#

设置文本的 (x, y, z) 位置。

参数:
xyz(浮点数, 浮点数, 浮点数)

三维空间中的位置。

zdir{'x', 'y', 'z', None, 3-tuple}

文本的方向。如果未指定,zdir 将不会改变。有关值的描述,请参见 get_dir_vector

set_z(z)[源代码][源代码]#

设置文本的 z 位置。

参数:
z浮动