geomotif.plotting
¶
Matplotlib helpers for looking at a design.
Kept out of the core so the engine stays dependency-free; importing this
module is the only thing that needs matplotlib
(pip install 'geomotif[plot]').
Three functions, for three questions:
- :func:
plot_design-- what does this design look like? - :func:
plot_grid-- how do these designs compare? - :func:
plot_comparison-- what does a spacing curve actually do?
The last is the library's headline idea in one image: the same motif, the same point count, sampled by different curves.
Classes:
| Name | Description |
|---|---|
Palette |
Every color a figure is drawn in. |
Functions:
| Name | Description |
|---|---|
plot_design |
Draw a design onto |
plot_grid |
Draw several designs as a grid of panels and return the figure. |
plot_comparison |
Draw one motif sampled by several spacing curves, side by side. |
spacing_label |
Return a panel title for a spacing curve, however it was expressed. |
Palette
dataclass
¶
Palette(page: str, surface: str, primary_ink: str, secondary_ink: str, muted: str, gridline: str, baseline: str, series: str)
Every color a figure is drawn in.
Gathered into one value rather than left as module constants so that a dark-mode figure is a different argument, not a different code path.
plot_design
¶
plot_design(design: Design, *, ax: Any = None, title: str | None = None, color: str | None = None, show_paths: bool = True, show_points: bool = False, dot_size: float = 14.0, linewidth: float = 1.4, guide: Design | None = None, center: Point | None = None, label_endpoints: bool = False, palette: Palette = LIGHT, grid: bool = True) -> Any
Draw a design onto ax (a new figure if omitted) and return the axes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
design
|
Design
|
What to draw. Its strokes become lines and its loose points become markers -- always, since a loose point is the only thing a scatter motif has to show. |
required |
ax
|
Axes
|
Target axes; a new styled figure is created when omitted. |
None
|
title
|
str
|
Panel title, drawn in secondary ink. |
None
|
color
|
str
|
Series color for lines and markers. Defaults to the palette's. A
stroke carrying a style of its own (:mod: |
None
|
show_paths
|
bool
|
Draw the strokes. |
True
|
show_points
|
bool
|
Draw a marker at every vertex of every stroke -- the "here is where the points landed" view this library exists for. Off by default, because a motif with four thousand vertices becomes a smear. |
False
|
dot_size
|
float
|
Marker area and line width, in matplotlib's usual units. |
14.0
|
linewidth
|
float
|
Marker area and line width, in matplotlib's usual units. |
14.0
|
guide
|
Design
|
A denser version of the same geometry, drawn as the smooth line under the markers. Without it the line connects the sample points themselves, which looks polygonal when the spacing is wide. |
None
|
center
|
(float, float)
|
Mark a point of interest -- a spiral's center -- with a small cross. |
None
|
label_endpoints
|
bool
|
Direct-label the design's first and last points "start" / "end". |
False
|
palette
|
Palette
|
:data: |
LIGHT
|
grid
|
bool
|
Draw the background grid. |
True
|
Source code in src/geomotif/plotting.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | |
plot_grid
¶
plot_grid(panels: Sequence[Panel], *, ncols: int = 2, panel_size: float = 4.4, suptitle: str | None = None, palette: Palette = LIGHT, **shared: Any) -> Any
Draw several designs as a grid of panels and return the figure.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
panels
|
sequence of (str, Design, dict)
|
Each entry is |
required |
ncols
|
int
|
Panels per row. |
2
|
panel_size
|
float
|
Side length of each square panel, in inches. |
4.4
|
suptitle
|
str
|
Figure-level title, drawn in primary ink. |
None
|
palette
|
Palette
|
Applied to every panel. |
LIGHT
|
**shared
|
Any
|
Passed to :func: |
{}
|
Source code in src/geomotif/plotting.py
plot_comparison
¶
plot_comparison(motif: SupportsBuild, spacings: Sequence[SpacingLike | None], *, count: int = 120, guide_count: int = 800, ncols: int = 2, panel_size: float = 4.4, suptitle: str | None = None, palette: Palette = LIGHT) -> Any
Draw one motif sampled by several spacing curves, side by side.
This is the library's whole premise in one figure: the same curve and the same number of points every time, and only where they land changes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
motif
|
Motif
|
What to sample. |
required |
spacings
|
sequence
|
One panel per entry. |
required |
count
|
int
|
Points per panel. |
120
|
guide_count
|
int
|
Points in the smooth line drawn underneath. |
800
|
ncols
|
int
|
As for :func: |
2
|
panel_size
|
int
|
As for :func: |
2
|
suptitle
|
int
|
As for :func: |
2
|
palette
|
int
|
As for :func: |
2
|
Source code in src/geomotif/plotting.py
spacing_label
¶
Return a panel title for a spacing curve, however it was expressed.