vibesketcher.render.panels¶
Labelled multi-panel figures at a stated physical width (#247).
compose_panels() lays existing figure SVGs (periodic figures, the
cyclic-topology schematic, powder overlays, scheme renders or any SVG that
passes the checks below) out in a grid, row by row in the order given, labels
them (a), (b), … in that order and writes one SVG, or PDF/PNG through the
publication extra. The physical width is stated: a single column (85 mm), a
double column (178 mm), or width_mm for a journal’s own measure. One SVG
unit is one point (1/72 in), as in every vibe-sketcher figure, so the PDF has
exactly that width.
Each panel keeps its own drawing: it is embedded as a nested <svg> with
its viewBox, scaled by one factor, and nothing in it is redrawn. Its id
attributes are prefixed per panel so two panels never share a clip path.
Panel scaling is stated, not guessed:
fit: every panel fills its column width;uniform: one factor for every panel, so relative sizes are kept;angstrom: every panel shows one angstrom at the same length, from the panel’s statedangstrom_per_unit(or its root attributedata-vibe-angstrom-per-unit); a panel without one is refused, and an optional common scale bar is drawn.
Panel SVG is untrusted input and fails closed: a DOCTYPE or entity, an
element outside the drawing subset (no script, foreignObject, image or
animation), an event attribute, an external reference (href or
url(...) not starting with #) or a style sheet other than an
@font-face block (which is dropped; the publication font is supplied at
conversion) is refused. Captions and the title may hold $...$ math
(vibesketcher.render.mathtext).
Module Attributes
Generic single- and double-column widths; give |
Functions
|
The width of one grid column in points: draw a panel at this width for true-size text. |
|
The labelled grid as SVG, or PDF/PNG through the publication extra. |
|
The labelled grid as standalone SVG (UTF-8), one unit per point. |
|
The labels of |
Classes
|
One panel: its SVG and what is stated about it. |
|
The grid, the physical width and the labels; every choice is stated. |
Exceptions
A panel or the layout cannot be composed as asked. |
- vibesketcher.render.panels.COLUMN_WIDTH_MM = {'double': 178.0, 'single': 85.0}¶
Generic single- and double-column widths; give
width_mmfor a journal’s own.
- class vibesketcher.render.panels.Panel(*, svg, caption=None, angstrom_per_unit=None)[source]¶
Bases:
BaseModelOne panel: its SVG and what is stated about it.
- Parameters:
- model_config = {'extra': 'forbid'}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class vibesketcher.render.panels.PanelOptions(*, columns=2, column='double', width_mm=None, gap_mm=3.0, labels='(a)', label_size_pt=9.0, label_bold=True, caption_size_pt=8.0, scale='fit', scale_bar_angstrom=None, max_height_mm=None, title=None)[source]¶
Bases:
BaseModelThe grid, the physical width and the labels; every choice is stated.
- Parameters:
column (Literal['single', 'double'])
width_mm (Annotated[float | None, Ge(ge=20.0), Le(le=500.0)])
labels (Literal['(a)', 'a', 'a)', '(A)', 'A', 'none'])
label_bold (bool)
scale (Literal['fit', 'uniform', 'angstrom'])
scale_bar_angstrom (Annotated[float | None, Gt(gt=0), Le(le=10000)])
max_height_mm (Annotated[float | None, Ge(ge=10.0), Le(le=500.0)])
- model_config = {'extra': 'forbid'}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- column: Literal['single', 'double']¶
- labels: LabelStyle¶
- scale: Literal['fit', 'uniform', 'angstrom']¶
- scale_bar_angstrom: float | None¶
a scale bar of this many angstrom under the grid.
- Type:
With
scale="angstrom"
- exception vibesketcher.render.panels.PanelRefused[source]¶
Bases:
RenderRefusedA panel or the layout cannot be composed as asked.
- vibesketcher.render.panels.compose_panels(panels, options=None, fmt='svg', *, dpi=300)[source]¶
The labelled grid as SVG, or PDF/PNG through the publication extra.
- vibesketcher.render.panels.compose_panels_svg(panels, options=None)[source]¶
The labelled grid as standalone SVG (UTF-8), one unit per point.
- Parameters:
options (PanelOptions | None)
- Return type:
- vibesketcher.render.panels.cell_width_pt(options=None, panels=None)[source]¶
The width of one grid column in points: draw a panel at this width for true-size text.
- Parameters:
options (PanelOptions | None)
panels (int | None)
- Return type: