Legends and annotations¶
See the legends and annotations guide for usage and backend behavior.
Configuration for a scalar-field colorbar or categorical legend.
Attributes:
| Name | Type | Description |
|---|---|---|
title |
str | None
|
Display title. |
units |
str | None
|
Optional physical units appended to the title. |
ticks |
int
|
Number of continuous ticks. Ignored for categorical legends. |
format |
str
|
Python numeric format specifier, such as |
position |
Literal['left', 'right']
|
Side of the image or viewer containing the legend. |
category_labels |
dict[str, str] | None
|
Optional mapping from stringified values to labels. |
width |
int
|
Raster legend panel width in pixels. |
Source code in hakowan/grammar/overlay.py
__post_init__()
¶
Validate tick count, panel width, and numeric format.
Source code in hakowan/grammar/overlay.py
Screen-space text annotation drawn over the rendered figure.
position uses normalized image coordinates with origin at the top-left.
Values outside [0, 1] are rejected to keep output deterministic.
Source code in hakowan/grammar/overlay.py
__post_init__()
¶
Validate annotation text, normalized position, and pixel sizes.
Source code in hakowan/grammar/overlay.py
Text callout anchored to a point in a view's local 3D coordinates.
position uses the geometry's local frame after transforms that bake
coordinates into mesh vertices. The label remains screen-facing; renderers
then apply the view's global transform, layout, and active camera.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Text string to display. |
required |
position
|
tuple[float, float, float]
|
3D point in the view's post-baked local geometry coordinates. |
required |
color
|
ColorLike
|
Text and arrow color. |
'white'
|
font_size
|
int
|
Font size in pixels. |
16
|
background
|
ColorLike | None
|
Background color of the text callout panel. |
'black'
|
padding
|
int
|
Internal padding in pixels around the text. |
4
|
offset
|
tuple[float, float] | None
|
Optional screen-space pixel offset |
None
|
arrow
|
bool
|
Whether to draw a leader from the panel to the anchor (default True). |
True
|