Skip to content

Add figsize and rc_context parameters to tee decorator#11

Merged
mmore500 merged 4 commits intomasterfrom
claude/implement-teeplot-figsize-s2Wut
Apr 21, 2026
Merged

Add figsize and rc_context parameters to tee decorator#11
mmore500 merged 4 commits intomasterfrom
claude/implement-teeplot-figsize-s2Wut

Conversation

@mmore500
Copy link
Copy Markdown
Owner

Summary

This PR adds two new parameters to the tee decorator to provide greater control over matplotlib figure properties and rendering context during plot generation.

Key Changes

  • New teeplot_figsize parameter: Allows users to specify the figure size as a tuple of (width, height) in inches. When provided, the current figure is resized after the plotter runs.
  • New teeplot_rc_context parameter: Accepts a mapping of matplotlib rcParams to apply via matplotlib.rc_context around the plotter, postprocess, and save steps. This allows temporary modification of matplotlib settings without affecting the global state.
  • Type safety improvements: Changed teeplot_outattrs parameter type from Dict[str, str] to Mapping[str, str] with a MappingProxyType default for better immutability semantics.
  • Import addition: Added import types to support MappingProxyType.
  • Context manager wrapping: Wrapped the plotter execution, postprocessing, and save operations in matplotlib.rc_context to ensure rcParams are properly scoped.

Implementation Details

  • The teeplot_rc_context parameter defaults to an empty MappingProxyType({}) to maintain backward compatibility while preventing accidental mutations.
  • Figure resizing via teeplot_figsize occurs after the plotter runs but before postprocessing, allowing postprocessing functions to work with the final figure dimensions.
  • Both the main plotting block and the save callback are wrapped in the rc_context to ensure consistent matplotlib settings throughout the entire operation.
  • Comprehensive test coverage added for both new parameters, including edge cases like teeplot_figsize=None and default rc_context behavior.

https://claude.ai/code/session_01VK9n4F4pX3Y9tsjR5DmUzr

claude added 4 commits April 21, 2026 16:59
Sets figure size via set_size_inches after the plotter runs, so it works
for both axes-level and figure-level plotting functions.
teeplot_rc_context wraps the plotter, postprocess, and save steps in a
matplotlib.rc_context so rcParam overrides are scoped to the single tee
call. Also documents the new teeplot_figsize kwarg in the README.
Avoids the mutable-default footgun by using an immutable mapping.
Avoids the mutable-default footgun by using an immutable mapping,
consistent with teeplot_rc_context.
Copy link
Copy Markdown
Owner Author

@mmore500 mmore500 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, ready to merge after CI

@mmore500 mmore500 merged commit bf9d8d1 into master Apr 21, 2026
36 of 37 checks passed
@mmore500 mmore500 deleted the claude/implement-teeplot-figsize-s2Wut branch April 21, 2026 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants