π New Release: Configurator Handler Registration
This release introduces a powerful extension point to the configuration system β Configurator.register_handler() β enabling dynamic responses to configuration changes.
β¨ New Feature: register_handler
You can now register custom handlers that execute automatically when specific settings are modified.
This is particularly useful for settings that require derived logic or side-effects, such as updating related Matplotlib parameters.
register_handler(name: str, func: Callable[[Any], Dict[str, Any]]) β NoneExample (enabled by default):
def _cycle_handler(value):
# Custom logic to create a cycler object from the value
return {'axes.prop_cycle': new_cycler}
rc.register_handler('cycle', _cycle_handler)Each handler function receives the new value of the setting and must return a dictionary mapping valid Matplotlib rc keys to their corresponding values. These updates are applied automatically to the runtime configuration.
π§© Why It Matters
This addition:
- Fixes an issue where
cycle:entries inultraplotrcwere not properly applied. - Decouples configuration logic from Matplotlib internals.
- Provides a clean mechanism for extending the configuration system with custom logic β without circular imports or hard-coded dependencies.
π§ Internal Improvements
- Refactored configuration update flow to support handler callbacks.
- Simplified
rcmanagement by delegating side-effectful updates to registered handlers.
π‘ Developer Note
This API is designed to be extensible. Future handlers may include dynamic color normalization, font synchronization, or interactive theme updates β all powered through the same mechanism.