Skip to content

Feature: Auto-share default with compatibility-aware grouping#560

Merged
cvanelteren merged 38 commits intomainfrom
feat/autoshare-auto-detect
Feb 11, 2026
Merged

Feature: Auto-share default with compatibility-aware grouping#560
cvanelteren merged 38 commits intomainfrom
feat/autoshare-auto-detect

Conversation

@cvanelteren
Copy link
Collaborator

Summary

This PR changes default subplot sharing to a compatibility-aware share='auto' mode, while preserving explicit share levels (0..4, aliases) as hard overrides.

The goal is to avoid noisy/inaccurate default sharing for mixed axis families (for example cartesian + polar) and to keep expected shared behavior for compatible grids.

Design Changes

  • Added parsing for share='auto' in Figure (sharex/sharey/share).
  • Added compatibility checks for auto-sharing groups:
    • axis family/projection compatibility (cartesian, polar, geo, external containers)
    • scale compatibility (xscale / yscale)
    • unit/converter domain compatibility
  • Reworked sharing group formation to partition row/column candidates into compatible subgroups.
  • Kept explicit sharing semantics (False/0, labels/1, limits/2, True/3, all/4):
    • explicit modes still attempt sharing and can warn on incompatibility.
  • Added auto-refresh flow for scale changes:
    • in auto mode, scale changes can unshare/re-evaluate groups.
    • after re-grouping, shared groups are autoscaled from sibling data to keep limits consistent.
  • Refactored repeated join/autoscale logic into figure helpers to reduce duplication.

Behavioral Expectations

  • Default behavior (subplots.share='auto'):
    • compatible axes share by default.
    • incompatible mixes are left unshared without warnings.
  • Explicit behavior (share='all', etc.):
    • sharing is forced where requested.
    • incompatible axes emit warning(s) and are skipped.
  • Local axis intent in auto mode:
    • formatting one axis to a different scale can split that axis from its previous share group.
  • Group intent in auto mode:
    • formatting a whole subplot grid preserves sharing and recomputes shared limits from all siblings.

Tests Added

  • default share mode is auto
  • auto mode skips mixed cartesian/polar without warning
  • explicit sharing warns for mixed cartesian/polar
  • auto mode local y-scale change splits group
  • explicit sharey propagates scale changes
  • auto mode grid y-scale change keeps shared limits
  • auto mode mixed x unit domains remain unshared after refresh

Docs Updated

  • API docstring for sharex/sharey/share now documents 'auto' and explicit override semantics.
  • Subplots user guide now documents all explicit levels plus 'auto' and includes a mixed cartesian/polar example.

Out of Scope

  • Full delegation-first share lifecycle redesign.
  • New user-facing API for compatibility policy customization.

@cvanelteren cvanelteren changed the title Auto-share default with compatibility-aware grouping Feature: Auto-share default with compatibility-aware grouping Feb 7, 2026
@cvanelteren cvanelteren marked this pull request as ready for review February 10, 2026 01:46
@cvanelteren cvanelteren requested a review from beckermr February 10, 2026 01:47
@cvanelteren cvanelteren merged commit 1041ac9 into main Feb 11, 2026
22 checks passed
@cvanelteren cvanelteren deleted the feat/autoshare-auto-detect branch February 11, 2026 21:39
K-Mirembe-Mercy pushed a commit to K-Mirembe-Mercy/UltraPlot that referenced this pull request Mar 22, 2026
…lot#560)

This PR adds compatibility-aware auto sharing for subplot axes so mixed axis families (e.g., cartesian + polar/geo) no longer produce avoidable sharing warnings or incorrect sharing side effects by default.

## Why this change
UltraPlot’s sharing model has explicit levels (`0` to `4`), but real figures often mix projections and axis types that are not compatible for full sharing. Previously, default sharing behavior could still attempt incompatible sharing, which led to noisy warnings and confusing outcomes.

## What this PR changes

- Adds `share='auto'` as a first-class sharing mode in figure/subplot parsing and docs.
- Keeps existing explicit levels (`0..4`, aliases) fully supported and unchanged in intent.
- In auto mode, sharing starts from level-3 semantics but only applies within compatible axis groups.
- Introduces compatibility checks used before sharing:
- axis family/class compatibility
- scale compatibility
- units/converter compatibility
- projection-related compatibility
- Partitions candidate shared axes into compatible groups, then shares per group.
- Deduplicates incompatible-share warnings so users see concise diagnostics instead of repeated noise.
- Updates cartesian `set_xscale` / `set_yscale` flow to unshare + refresh in auto mode when scale changes would invalidate compatibility.
- Documents auto-sharing behavior and mixed-axis examples in `docs/subplots.p`.


---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
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