Configuration

Process-wide defaults for dartwork-mpl behaviour toggles. Mutate the config singleton once near the top of your program to flip the default of every call site that reads it — without having to thread the keyword through each individual call.

Per-call keyword arguments always win over the global default.

Example

import matplotlib.pyplot as plt
import dartwork_mpl as dm

dm.style.use("scientific")

# Flip orphan-tick adoption off globally.
dm.config.adopt_orphan_tick_font = False

fig, ax = plt.subplots(figsize=dm.figsize("13cm", "standard"))
ax.plot([1, 2, 3], [1, 4, 9])      # no axis label on x
dm.simple_layout(fig)              # tick fonts left untouched
dm.save_formats(fig, "out", formats=("png",))   # also untouched

# Per-call override still works.
dm.simple_layout(fig, adopt_orphan_tick_font=True)

# Or scope the change to a block.
with dm.config.override(adopt_orphan_tick_font=True):
    dm.save_formats(fig, "out", formats=("png",))

API

class dartwork_mpl.Config(adopt_orphan_tick_font: bool = True, warn_on_orphan_tick_adoption: bool = False)[source]

Process-wide dartwork-mpl defaults.

Slotted so a typo’d direct assignment (dm.config.adopt_orphan_tick_fonts = False — note the plural) raises AttributeError instead of silently creating a dead attribute that never affects behaviour.

adopt_orphan_tick_font

Fallback default for the adopt_orphan_tick_font keyword on dartwork_mpl.simple_layout(), dartwork_mpl.save_formats(), and dartwork_mpl.save_and_show(). Each of those functions accepts True / False / None (the call-site default); None is read here. Set this to False to leave orphan-axis tick fonts alone everywhere by default. Per-call overrides (passing True / False explicitly) still win.

Type:

bool, default True

warn_on_orphan_tick_adoption

When True, emit a one-time UserWarning every time orphan-tick font adoption mutates a figure (via dartwork_mpl.layout.adopt_axis_label_font() or its drivers simple_layout(), save_formats(), save_and_show()). Useful when debugging a figure whose ticks change unexpectedly after a save — or when running under matplotlib’s constrained_layout, where the font change can trigger a re-layout on the next draw. Default is off so the common path stays quiet.

Type:

bool, default False

override(**overrides: object) Iterator[None][source]

Temporarily override one or more defaults inside a with block.

Restores every overridden field to its previous value on exit — including the exception path. Raises AttributeError for any keyword that is not an existing Config field, so a typo can’t silently shadow the singleton with a new attribute.

Parameters:

**overridesfield_name=value pairs. Every name must already exist on Config.

Yields:

None – The block runs with the overridden defaults active.

Example

with dm.config.override(adopt_orphan_tick_font=False):
    dm.simple_layout(fig)   # adoption skipped just here
dm.simple_layout(fig)        # adoption re-applied (back to default)
dartwork_mpl.config

Process-wide dartwork-mpl defaults.

Slotted so a typo’d direct assignment (dm.config.adopt_orphan_tick_fonts = False — note the plural) raises AttributeError instead of silently creating a dead attribute that never affects behaviour.

dartwork_mpl.adopt_orphan_tick_font

Fallback default for the adopt_orphan_tick_font keyword on dartwork_mpl.simple_layout(), dartwork_mpl.save_formats(), and dartwork_mpl.save_and_show(). Each of those functions accepts True / False / None (the call-site default); None is read here. Set this to False to leave orphan-axis tick fonts alone everywhere by default. Per-call overrides (passing True / False explicitly) still win.

Type:

bool, default True

dartwork_mpl.warn_on_orphan_tick_adoption

When True, emit a one-time UserWarning every time orphan-tick font adoption mutates a figure (via dartwork_mpl.layout.adopt_axis_label_font() or its drivers simple_layout(), save_formats(), save_and_show()). Useful when debugging a figure whose ticks change unexpectedly after a save — or when running under matplotlib’s constrained_layout, where the font change can trigger a re-layout on the next draw. Default is off so the common path stays quiet.

Type:

bool, default False