Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
[ENH]: add Figure.align_titles() functionality#22793
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
We are working on documentation/testing and need to squash the commits. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Thank you for opening your first PR into Matplotlib!
If you have not heard from us in a while, please feel free to ping@matplotlib/developers
or anyone who has commented on the PR. Most of our reviewers are volunteers and sometimes things fall through the cracks.
You can also join uson gitter for real-time discussion.
For details on testing, writing docs, and our review process, please seethe developer guide
We strive to be a welcoming and open project. Please follow ourCode of Conduct.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
@@ -1241,6 +1242,60 @@ def align_xlabels(self, axs=None): | |||
# grouper for groups of xlabels to align | |||
self._align_label_groups['x'].join(ax, axc) | |||
def align_titles(self, axs=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I wonder if we want to addalign_titles
toalign_labels
? Though this would be a breaking change ofalign_labels
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Overall this looks good! Not set on rolling into_align_label_groups
, but might be more compact.
We aligned the titles by changing the image bounding boxes, which works with |
I am not on my computer for a few days to look properly what you mean. However the alignment should work the same as for x and y labels. All of them may need a draw before they are correct to get the text sizes correct. |
update testfirstcopy a bbox function to axesBase from figureadd broken code? commented outalign titles worksfinish code and add testsadd demoremove readme2
test cases
@@ -0,0 +1,26 @@ | |||
""" | |||
=============== | |||
Aligning Labels |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
AligningLabels | |
AligningTitles |
?
@@ -2950,7 +2950,7 @@ def _update_title_position(self, renderer): | |||
_log.debug('title position was updated manually, not adjusting') | |||
return | |||
titles =(self.title, self._left_title, self._right_title) | |||
titles =[self.title, self._left_title, self._right_title] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Is this required? It doesn't look like you are actually modifyingtitles
.
@@ -2950,7 +2950,7 @@ def _update_title_position(self, renderer): | |||
_log.debug('title position was updated manually, not adjusting') | |||
return | |||
titles =(self.title, self._left_title, self._right_title) | |||
titles =[self.title, self._left_title, self._right_title] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
titles=[self.title,self._left_title,self._right_title] | |
titles=(self.title,self._left_title,self._right_title) |
Hi@aswarner - can we help you move this forward? Thanks! |
ping@aswarner just had another request for this feature today. If you are not moving forward with the PR, should we open up to other folks? Thanks! |
Closing in favour of#27952. |
PR Summary
Resolves#22376 . Add
Figure.align_titles()
function, which automatically aligns titles of subplots on a single figure, in the style ofalign_labels()
.NOTE: This PR contains tested code but we still need to complete documentation and pytest.
PR Checklist
Tests and Styling
pytest
passes).flake8-docstrings
and runflake8 --docstring-convention=all
).Documentation
doc/users/next_whats_new/
(follow instructions in README.rst there).doc/api/next_api_changes/
(follow instructions in README.rst there).