You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|**Bundled font**| CMU Sans Serif — auto-registered, no system install needed |
19
+
|**Range frame**| Tufte-style axis frame trimmed to the data range, with automatic nice-number bounds for numeric axes and full support for categorical axes |
20
+
|**Label helpers**|`ylabel_top` — horizontal y-label placed above the top tick |
<divalign="center"> <imgsrc="docs/static/plotting_functions.png"alt="Helper function examples"width="100%"/> <p><em>Left: Range Frame; Center: Top Y-Label; Right: Identity Line</em></p> </div>
153
+
#### Parameters
154
+
155
+
| Parameter | Default | Description |
156
+
|---|---|---|
157
+
|`ax`| — | Matplotlib `Axes` object |
158
+
|`x`, `y`| — | Data arrays (numeric or string/categorical) |
159
+
|`pad`|`0.1`| Padding factor applied to both axes (only used when `nice=False`) |
160
+
|`pad_x`|`None`| Per-axis padding near the x-axis (vertical). Overrides `pad`. |
161
+
|`pad_y`|`None`| Per-axis padding near the y-axis (horizontal). Overrides `pad`. |
162
+
|`nice`|`True`| Snap numeric spine bounds to nice tick positions that bracket the data. When `True`, padding parameters are ignored for numeric axes. |
124
163
125
-
### Decomposing a Figure by Legend Entries
164
+
### `ylabel_top` — horizontal y-label above the axis
126
165
127
-
`decompose_figure` takes a figure (or axes) that contains multiple labeled series and returns a list of `(label, figure)` tuples — one separate figure per legend entry. This is useful when you want to highlight individual series from a combined plot, e.g. to include them separately in a paper or presentation.
166
+
Places the y-axis label horizontally above the top tick, making it easier to
167
+
read without head-tilting:
168
+
169
+
```python
170
+
from lama_aesthetics.plotutils import ylabel_top
171
+
172
+
fig, ax = plt.subplots()
173
+
ax.plot([0, 1, 2], [0, 1, 4])
174
+
ylabel_top("Energy (eV)", ax=ax)
175
+
```
176
+
177
+
| Parameter | Default | Description |
178
+
|---|---|---|
179
+
|`string`| — | Label text |
180
+
|`ax`|`None`| Axes (defaults to `plt.gca()`) |
181
+
|`x_pad`|`0.01`| Horizontal offset in axes coordinates |
182
+
|`y_pad`|`0.02`| Vertical offset above the top tick |
183
+
184
+
### `add_identity` — dynamic 1:1 reference line
185
+
186
+
Adds a diagonal identity line that automatically adjusts when the axis limits
187
+
change (e.g. during zoom or pan):
188
+
189
+
```python
190
+
from lama_aesthetics.plotutils import add_identity
# Split into individual figures — one per labeled series
148
-
parts = decompose_figure(fig) # also accepts an Axes directly
221
+
parts = decompose_figure(fig) # also accepts an Axes directly
149
222
150
223
for label, part_fig in parts:
151
224
part_fig.savefig(f"{label}.png")
152
225
plt.close(part_fig)
153
226
```
154
227
155
-
Each decomposed figure inherits the axis labels, title, limits, and scale of the original. Pass `show_legend=False` to omit the legend from the individual figures.
228
+
Each decomposed figure inherits axis labels, title, limits, scale, tick
229
+
positions, spine visibility, and grid state from the original. Pass
230
+
`show_legend=False` to omit the legend from the individual figures.
231
+
232
+
**Supported artist types:** line plots (`plot`), scatter plots (`scatter`),
233
+
bar charts (`bar`), and filled regions (`fill_between`).
234
+
235
+
---
236
+
237
+
## Figure dimension constants
238
+
239
+
Predefined sizes based on common journal column widths and the golden ratio:
0 commit comments