Skip to content

Conversation

@cvanelteren
Copy link
Collaborator

Closes #297,#270

This PR introduces UltraLayout, a novel constraint-based layout system using kiwisolver that enables aesthetically pleasing positioning for non-orthogonal subplot arrangements (e.g., [[1, 1, 2, 2], [0, 3, 3, 0]] where subplot 3 should be centered between subplots 1 and 2). The existing gridspec works great for orthogonal layouts but fails to produce visually balanced results when subplots span multiple rows/columns in non-aligned ways. UltraLayout automatically detects non-orthogonal layouts, applies constraint satisfaction to compute optimal positions that respect spacing, ratios, and aesthetic balance (e.g., centering subplots between neighbors), and gracefully falls back to the standard grid layout if kiwisolver is not installed or for orthogonal arrangements. This enhancement is fully backward compatible, adds zero overhead for standard grid layouts, includes comprehensive test coverage in ultraplot/tests/test_ultralayout.py, and provides a foundation for more sophisticated layout constraints in the future.

Make subplot param probes backend-safe: GridSpec.get_subplot_params now returns a read-only snapshot of our margins/spaces and locally_modified_subplot_params returns False. This keeps Positron/other backends from erroring while preserving our restriction on mutating Matplotlib’s subplot params.

@cvanelteren cvanelteren requested a review from beckermr January 16, 2026 22:22
@cvanelteren cvanelteren added this to the v2.0 milestone Jan 16, 2026
@cvanelteren
Copy link
Collaborator Author

Made a local error with the history so this is a restored version of the old PR.

@codecov
Copy link

codecov bot commented Jan 17, 2026

Codecov Report

❌ Patch coverage is 83.88158% with 98 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
ultraplot/gridspec.py 63.25% 39 Missing and 22 partials ⚠️
ultraplot/ultralayout.py 86.79% 19 Missing and 9 partials ⚠️
ultraplot/axes/base.py 85.18% 3 Missing and 5 partials ⚠️
ultraplot/figure.py 50.00% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

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.

Colorbar not aligning with custom layout

2 participants