Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Use SubplotSpec row/colspans more, and deprecate get_rows_columns. #16618

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

Merged
merged 1 commit into from
Mar 25, 2020

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Mar 1, 2020

and simplify constrained_layout by using rowspan/colspan instead.

(The deprecation was suggested in #13544 (comment).)

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@anntzer anntzer added this to the v3.3.0 milestone Mar 1, 2020
@QuLogic
Copy link
Member

QuLogic commented Mar 12, 2020

This is pretty long to be considered just a deprecation.

@QuLogic QuLogic requested a review from jklymak March 12, 2020 01:31
Copy link
Member

@jklymak jklymak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall using the colspan and rowspan is nicer than what was being done before and helpful. There was one block in there where @anntzer had to obfuscate a relatively straightforward piece of code to the point that I can't really tell what it does for very little savings IMHO.

pos, ax = pos_ax
return pos

minrow, minrow_ax = min(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code block is pretty obfuscated compared to the original.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair enough, went for some compromise...

@anntzer
Copy link
Contributor Author

anntzer commented Mar 12, 2020

@QuLogic fair enough (though replacing get_rows_columns() everywhere is necessarily going to involve quite a few changes), do you have a suggested path forward here?

if location == 'right':
if col_stop <= maxcol:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jklymak btw, are you really sure about whether the various inequalities here must be >/< or >=/<=? I'm not 100% sure they're all correct, and a comment explaining strict vs non-strict equalities may help...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, you are the one who decided it should all be off by one, so I assumed you carefully checked ;-) It passes the tests so that is encouraging. There are lots of quite complex tests, so its hard to see how you broke something if it passes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually was referring to the original version.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ha ha, OK. But again, the tests are pretty complex and don't fail in any weird ways. If these inequalities were not correct, its a little hard to see how the whole thing would work. But I can go through and try and remember why each is the way it is.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was slightly puzzled by them, so if you can add a comment that would be nice, but there's no urgency whatsoever.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are all correct. Lets say the parents of the colorbar span columns 1-3 of a six column layout (indexed 0, 1, 2, 3, 4, 5). maxrow is then 3. If a subplot span stops at 3 or less then the colorbar is to the right (I assume in this case that subspec.colspan.stop == 4). If the subplot starts 4 or higher the colorbar is to its left.

Note its entirely possible for a subplot to not be positioned relative to the colorbar. i.e. if in another row it spans columns 0-5 that is perfectly allowed and neither stacking would happen. Saying that I wonder if I do have a bug in here where I should only call hstack if order is not empty. But maybe this should go in first and I fix things like that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I guess I'll just trust you on this for now and leave things as they are (with the mechanical translation) ;)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think thats fine, but I will go through and fix this after your translation is in.

@QuLogic
Copy link
Member

QuLogic commented Mar 12, 2020

@QuLogic fair enough (though replacing get_rows_columns() everywhere is necessarily going to involve quite a few changes), do you have a suggested path forward here?

Just don't call it (the PR) a deprecation ;) The deprecation is a side effect of the re-factor, even if it may have been its initial cause.

@anntzer anntzer changed the title Deprecate SubplotSpec.get_rows_columns. Use SubplotSpec row/colspans more, and deprecate get_rows_columns. Mar 12, 2020
@anntzer
Copy link
Contributor Author

anntzer commented Mar 12, 2020

fair enough, edited the commit message :)

lib/matplotlib/_constrained_layout.py Outdated Show resolved Hide resolved
height1 = heights[idx1]
# Horizontally align axes spines if they have the same min or max:
if not alignleft and colspan0.start == colspan1.start:
_log.debug('same start columns; line up layoutbox lefts')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bit weird these debug messages, because they never mention which ax0 or ax1 they're talking about.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume these were intended to help debug the original implementation in simple cases where it's "clear" which axes are involved...

lib/matplotlib/_constrained_layout.py Outdated Show resolved Hide resolved
lib/matplotlib/_constrained_layout.py Outdated Show resolved Hide resolved
lib/matplotlib/_constrained_layout.py Outdated Show resolved Hide resolved
lib/matplotlib/_constrained_layout.py Outdated Show resolved Hide resolved
lib/matplotlib/_constrained_layout.py Outdated Show resolved Hide resolved
@anntzer
Copy link
Contributor Author

anntzer commented Mar 24, 2020

rebased

@QuLogic
Copy link
Member

QuLogic commented Mar 24, 2020

Tests fail due to removed imports.

@QuLogic
Copy link
Member

QuLogic commented Mar 24, 2020

#16897

@QuLogic QuLogic closed this Mar 24, 2020
@QuLogic QuLogic reopened this Mar 24, 2020
@QuLogic QuLogic merged commit ce9c860 into matplotlib:master Mar 25, 2020
@anntzer anntzer deleted the subplotspans branch March 25, 2020 07:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.