Conversation
lib/matplotlib/layout_engine.py
Outdated
| hspace=mpl.rcParams['figure.constrained_layout.hspace']) | ||
| # set anything that was passed in (None will be ignored): | ||
| self.set(w_pad=w_pad, h_pad=h_pad, wspace=wspace, hspace=hspace) | ||
| # see CompressedLayoutEngine below... |
There was a problem hiding this comment.
This comment seems wrong now?
There was a problem hiding this comment.
Ooops, yes, I decided against needing a subclass here.
dcca890 to
8175f87
Compare
e445e28 to
777b8ef
Compare
ead8ac7 to
e303fbb
Compare
lib/matplotlib/layout_engine.py
Outdated
| hspace=mpl.rcParams['figure.constrained_layout.hspace']) | ||
| # set anything that was passed in (None will be ignored): | ||
| self.set(w_pad=w_pad, h_pad=h_pad, wspace=wspace, hspace=hspace) | ||
| # see CompressedLayoutEngine below... |
| fig, axs = plt.subplots(2, 2, figsize=(5, 3), | ||
| sharex=True, sharey=True, layout='compressed') | ||
| for ax in axs.flat: | ||
| ax.imshow(arr) | ||
| fig.suptitle("fixed-aspect plots, layout='compressed'") |
There was a problem hiding this comment.
This seems to look the same as the constrained version?
There was a problem hiding this comment.
but I have no idea what is happening here. This example works fine manually, just using Agg, etc. I'm flummoxed why the sphinx version doesn't work...
There was a problem hiding this comment.
Fixed in newest version - there was some weird interactions between the rcParam and subsequent calls. maybe worth chasing down, but I could not reproduce without sphinx-gallery, so I guess sphinx-galery is using some weird rcParam contexts?
There was a problem hiding this comment.
I think the context remains the same through a single file.
There was a problem hiding this comment.
Yes, but even if I change the rcParam in a normal script, and then specify the kwarg, compress works fine. But in sphinx- gallery it has this weird problem.
5380aa1 to
dbcb46c
Compare
f14b4bb to
1adfa9d
Compare
1adfa9d to
421c99e
Compare
| fig, axs = plt.subplots(2, 2, figsize=(5, 3), | ||
| sharex=True, sharey=True, layout='compressed') | ||
| for ax in axs.flat: | ||
| ax.imshow(arr) | ||
| fig.suptitle("fixed-aspect plots, layout='compressed'") |
There was a problem hiding this comment.
I think the context remains the same through a single file.
| A value of 0.2 for a three-column layout would have a space | ||
| of 0.1 of the figure width between each column. | ||
| If h/wspace < h/w_pad, then the pads are used instead. | ||
|
|
There was a problem hiding this comment.
For consistency with above, this empty line should be here (and one added after the rect description) or all above also removed.
There was a problem hiding this comment.
Sure, though this is private, so never rendered in the docs ;-)
421c99e to
1984d55
Compare
Adds compress=True to compressed layout engine. Works for compact axes grids.
1984d55 to
44df2db
Compare
|
I've marked merge with single review. This is pretty stand alone, so it shouldn't break anyone. However, happy to get a second review. I'll merge by next Friday if it doesn't attract one. |
|
Thanks everyone for your work on this! |
Thanks for creating this! 😄 |
PR Summary
Replaces #20016
We often want a grid of fixed-aspect ratio axes, but constrained_layout and tigt_layout leave large blank spaces between the axes because they only work with the original axes positions, not the aspect-modified versions.
Here I proposed an extension to constrianed_layout that works for simple grids of axes...
Old:
New:
Code
Failures...
This isn't perfect, and that is why it is not in "constrained_layout" Folks should be able to turn this off... This example isn't terrible, but its not very good either, though
Or:
PR Checklist
Tests and Styling
pytestpasses).flake8-docstringsand 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).