-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix padding, spacing, and alignment of labels etc for GridSpecFromSubplotSpec
with layout="constrained"
#28903
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?
Fix padding, spacing, and alignment of labels etc for GridSpecFromSubplotSpec
with layout="constrained"
#28903
Conversation
…ns of their parent
OK, you are proposing a different decision metric for what constrained layout is trying to do. I understand that you want the grids to line up as much as possible, even between sub-gridspecs. However, currently constrained layout tries to maximize the size of axes within their sub-gridspec at the expense of inter-subgridspec alignment. It was designed such that if two different sets of axes are in different sub gridspecs, they are considered independently, with the belief that if they are not in the same subgridspec, then there is no good reason for the axes to line up with each other because they are presumably different data/visualization types. Indeed, I often go out of my way to make axes not line up when I have two subplots with different visualizations so the eye doesn't try to line them up accidentally. This independence also favours maximizing the size of the axes, and hence enlarging the data presentation. So while I appreciate what you are trying to do here, I don't consider the current behaviour a bug, and I'm not convinced the change is practically better. |
I'm sorry but I don't understand the criterion. You mentioned in my previous merge request "If the outer container also has a margin that should be respected as well." But in the current implementation (3.9.2), subgrids don't respect the margins of their outer containers (see images above), which makes it impossible to add spaces between different subgrids (which is the use case I care about - I want to do something like the image below, and it seems to me like a bug that this doesn't work in 3.9.2). FYI My ultimate goal here was just to allow spacing between different subgrids (which is not preserved in 3.9.2), which I mentioned in #28891 . As I mentioned in that issue, a one-line solution to allowing space between subgrids (without necessarily aligning axes in different subgrids) was just to include |
I don't think I objected to that one-line solution. I apologize if it seemed I did. I was concerned about the other work that removed the outer margin. If it were me, I'd put in the change with the one-line solution, let's see what breaks. If after that you want to propose further changes, we can see where that goes. |
Sounds like a good plan. I have a few other things I need to focus on first, but will hopefully get round to opening a PR for the 1-line solution end of this week/beginning of next. |
PR summary
Alternative solution to the issues addressed in PR #28895 , which additionally matches alignment of axis labels, axis tick labels etc for nested grids. Closes #28891 and #28894 . Below is an example of outputs created with this fix applied compared to the same code run with
matplotlib 3.9.2
. See linked issues and PR for further discussion.With fix (this PR):
matplotlib 3.9.2
:PR checklist