Support moving axes to the opposite side of the panel#1085
Merged
Conversation
(cherry picked from commit 7a65e28)
Add a scale_position mixin that validates and carries the axis position
("left"/"right" for y, "top"/"bottom" for x), and a scale_position_view
that propagates the resolved position through coord_cartesian to the coord.
Add per-side axis theme hierarchy (axis_text/ticks/line/title each gain _x_top/_x_bottom, _y_left/_y_right children under the existing parent). Each child styles its own side's artist; coord.setup_ax makes the active side's ticks/spine visible per scale.position. coord_flip rotates the position with the swap. Delete the dead mpl<3.10 tick-param shim.
… axes Side-scoped extent accessors on the layout items (label1/label2, tick1line/tick2line via side_artists); top_space/right_space gain axis attrs and the side-spaces read the scoped accessors + side-scoped margins; per-side axis-title placement; tick text justified into the band past the panel's far edge. Anchor top/right titles at the band's panel edge (y1/x1, not y2/x2, which cropped them) and align them across compositions via axis_title_alignment, matching bottom/left. Default plots are byte-identical.
The axis text/title gap is the single margin between the text and the panel. Each side reads the margin edge that actually faces the panel: top for a bottom axis, bottom for a top axis, right for a left axis, left for a right axis. The value is read from the side-scoped themeable (axis_text_x_top, axis_title_y_right, ...), which cascades to the parent by default, so a user can override one side's margin without touching the others. The themes (gray, matplotlib, seaborn) set both edges of the axis text/title margins so every position has a gap. Docstrings updated to match. Default plots unchanged.
New baselines for the axis-position feature: x_axis_top_continuous, y_axis_right_continuous, x_axis_top_discrete, coord_flip_x_top, facet_wrap_y_right. theme_seaborn is refreshed for the per-side axis text/title margins.
Remove the temporal coupling where Layout.setup pre-assigned self.facet.plot = plot so axis_positions() could reach self.plot.scales before facet.setup(plot) ran at draw time. axis_positions() now takes `scales` explicitly and uses an explicit `is None` check (replacing getattr) so a present scale missing `position` becomes a type error rather than a silent default. compute_layout gains `axis_positions: tuple[str, str]` in the base class and both subclasses (facet_grid, facet_wrap, facet_null). Layout.setup resolves the positions from plot.scales and passes them in, dropping the early assignment.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1085 +/- ##
==========================================
+ Coverage 87.16% 87.25% +0.09%
==========================================
Files 208 208
Lines 14375 14557 +182
Branches 1796 1812 +16
==========================================
+ Hits 12530 12702 +172
- Misses 1272 1281 +9
- Partials 573 574 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
|
Will this eventually lead to dual axis plots? |
Owner
Author
A big yes. And not eventually, rather immediately! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds the ability to place a position scale's axis on the opposite side of the panel — the x axis on top, the y axis on the right — together with per-side theming so each axis side can be styled independently.