label#

k3d.factory.label(text, position=(0, 0, 0), color=255, on_top=True, size=1.0, max_length=0.8, mode='dynamic', is_html=False, label_box=True, name=None, group=None, custom_data=None, compression_level=0, **kwargs)[source]#

Create a Text drawable for 3D-positioned text labels.

Parameters
  • text (str) – Text content.

  • position (tuple, optional) – (x, y, z) coordinates of text position, by default (0, 0, 0).

  • color (int, optional) – Hex color of the text, by default _default_color.

  • on_top (bool, optional) – Render order with 3d object, by default True.

  • size (float, optional) – Font size in ‘em’ HTML units, by default 1.0.

  • name (str, optional) – Object name, by default None.

  • group (str, optional) – Name of a group, by default None.

  • max_length (float, optional) – Maximum length of line in % of half screen size (only when mode is dynamic), by default 0.8.

  • mode ({'dynamic', 'local', 'side'}, optional) – Label node, by default “dynamic”.

  • is_html (bool, optional) – Interprete text as HTMl instead of KaTeX, by default False.

  • label_box (bool, optional) – Label background box, by default True.

  • custom_data (dict) – A object with custom data attached to object.

  • compression_level (int, optional) – Level of data compression [-1, 9], by default 0.

  • **kwargs – For other keyword-only arguments, see process_transform_arguments.

Returns

Label Drawable.

Return type

Label

See also

Examples#

Basic#

import k3d

plt_label1 = k3d.label('Insert text here',
                        position=(1, 1, 1))
plt_label2 = k3d.label('Insert text here (HTML)',
                        position=(-1, -1, -1),
                        is_html=True)

plot = k3d.plot()
plot += plt_label1
plot += plt_label2
plot.display()

Modes#

import k3d

plt_points = k3d.points([[1, 1, 1], [0, 0, 0], [-1, -1, -1]],
                        point_size=0.5,
                        shader='flat',
                        colors=[0xff0000, 0x00ff00, 0x0000ff])

plt_label_dynamic = k3d.label('Dynamic',
                              position=(1, 1, 1),
                              mode='dynamic',
                              label_box=False,
                              color=0xff0000)
plt_label_local = k3d.label('Local',
                            position=(0, 0, 0),
                            mode='local',
                            label_box=False,
                            color=0x00ff00)
plt_label_side = k3d.label('Side',
                            position=(-1, -1, -1),
                            mode='side',
                            label_box=False,
                            color=0x0000ff)

plot = k3d.plot()
plot += plt_points
plot += plt_label_dynamic
plot += plt_label_local
plot += plt_label_side
plot.display()