-
Notifications
You must be signed in to change notification settings - Fork 18
Add UltraLayout: Advanced constraint-based positioning for non-orthogonal subplot arrangements #430
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
This PR is turning into a beast. It replaces one of the fundamentals of UltraPlot: its layout mechanism. It improves the layout by moving towards a constraint based approach (using kiwisolver). In the PR we separate To aid in the review, I constructed the following checklist. I am aiming for a 2.0 release giving us some time to review and or iron out some kinks before merging. I am not expecting the 2.0 to be there for a while (couple of months) as we slowly progress and clean existing PRs with higher priority. Say we aim for the latest being May 2026. The visual tests look good (locally) even though they fail on size, visually they look good PR Review Checklist (novo-layout)
|


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 inultraplot/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_paramsnow returns a read-only snapshot of our margins/spaces andlocally_modified_subplot_paramsreturns False. This keeps Positron/other backends from erroring while preserving our restriction on mutating Matplotlib’s subplot params.