API reference — Specs¶
behaviz.spec.plot_spec ¶
PlotSpec
dataclass
¶
Master spec object. Compose sub-specs for full control, or rely on defaults and override only what you need.
Quick-start¶
spec = PlotSpec(title="My Plot", x=AxisSpec(label="Time", unit="s")) plot_line(ax, t, v, spec)
Source code in behaviz/spec/plot_spec.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 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 225 226 227 228 229 230 231 | |
preset
classmethod
¶
preset(name, style_dict=None)
Return a PlotSpec tuned for a specific output target.
paper → small figure, thin lines, no grid poster → large figure, thick lines, big fonts notebook → medium figure, grid on, slightly transparent markers dark → dark background, bright colours paper → small figure, thin lines, no grid poster → large figure, thick lines, big fonts notebook → medium figure, grid on, slightly transparent markers dark → dark background, bright colours presentation → large 12x12in slide figure, thick lines, 24pt fonts presentation_dark → presentation on a #1E1E1E dark background, muted colors print → 8x8cm Word/print figure, thin lines, 14pt fonts
Source code in behaviz/spec/plot_spec.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | |
from_labels
classmethod
¶
from_labels(xlabel, ylabel, xunit='', yunit='', **kwargs)
Shortest path when you only care about axis labels.
Source code in behaviz/spec/plot_spec.py
167 168 169 170 171 172 173 174 | |
behaviz.spec.axis_spec ¶
AxisSpec
dataclass
¶
Everything that describes a single axis.
Source code in behaviz/spec/axis_spec.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | |
behaviz.spec.figure_spec ¶
FigureSpec
dataclass
¶
Figure-level properties.
Source code in behaviz/spec/figure_spec.py
15 16 17 18 19 20 21 22 23 24 25 | |
behaviz.spec.colorbar_spec ¶
ColorbarSpec
dataclass
¶
Styling for a colorbar attached to a colour-mapped plot (e.g. plot_image).
Pass it to a plot's colorbar= keyword, or use the shorthands handled by
:meth:coerce: colorbar=True for a default bar, colorbar="label" for
a labelled one.
Fields¶
label : str
Text shown beside the bar.
location : "right" | "left" | "top" | "bottom"
Side of the axes to place the bar on (sets orientation automatically).
ticks : list | None
Explicit tick positions. None → automatic.
tick_fmt : str | None
printf-style tick format, e.g. "%.1f".
fraction : float
matplotlib sizing. The default (0.046) makes the bar match the axes
height — the usual "magic number" — so users don't have to.
pad : float | None
Gap between axes and bar (axes-fraction). None picks a location-aware
default that clears the axis labels (small on the right, larger on the
bottom/left where tick labels live).
fontsize : float
Label and tick-label size.
Source code in behaviz/spec/colorbar_spec.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | |
resolved_pad ¶
resolved_pad()
The pad to use — explicit if set, else a location-aware default.
Source code in behaviz/spec/colorbar_spec.py
45 46 47 48 49 | |
coerce
classmethod
¶
coerce(value)
Normalise a colorbar argument (True/str/spec) to a spec.
Source code in behaviz/spec/colorbar_spec.py
51 52 53 54 55 56 57 58 | |