Skip to content

Conversation

@nathanhu0
Copy link
Owner

Summary

  • Implements subfigure_mosaic method that creates SubFigure layouts using the same ASCII art or nested list syntax as subplot_mosaic
  • Refactored existing subplot_mosaic to share implementation via a private _do_mosaic method
  • Addresses [ENH]: subfigure_mosaic matplotlib/matplotlib#25949

Implementation Details

  • Extracted common mosaic logic into _do_mosaic with dependency injection for the child creation method
  • subplot_mosaic passes self.add_subplot as the child creator
  • subfigure_mosaic passes self.add_subfigure as the child creator
  • All subfigures created are flat (direct children of the calling figure/subfigure)
  • Users can create hierarchies by calling subfigure_mosaic on a SubFigure

Testing

  • Added 5 comprehensive tests in TestSubfigureMosaic class
  • Tests cover: basic functionality, string input, empty cells, width/height ratios, and nested hierarchies
  • All 40 existing TestSubplotMosaic tests still pass without modification

API Decisions

  • sharex/sharey parameters not supported for subfigures (they're containers without axes at creation time)
  • Users can still share axes between subfigures after creating axes within them
  • Follows same flat structure approach as subplot_mosaic - nesting in spec is for layout only

Test plan

  • Run new subfigure_mosaic tests: pytest lib/matplotlib/tests/test_figure.py::TestSubfigureMosaic
  • Verify existing tests still pass: pytest lib/matplotlib/tests/test_figure.py::TestSubplotMosaic
  • Add gallery example (future work)
  • Add What's New entry (future work)

🤖 Generated with Claude Code

- Refactored subplot_mosaic into shared _do_mosaic private method
- Added subfigure_mosaic that creates SubFigure layouts using same syntax
- Added comprehensive tests for subfigure_mosaic functionality
- Tests verify flat subfigure creation and nested hierarchy support
- All 40 existing subplot_mosaic tests still pass

Addresses matplotlib#25949

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.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