-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
ConnectionPatch across axes needs to be excluded from layout management #14907
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
Comments
Want to try a PR along those lines? Might also be worth looking at constrained layout tutorial and letting us know where this could be better explained. I think another solution to your issue would have been if you had made the connector a figure artist rather than an axes artist. Then the layout manager wouldn’t have considered the patch as something it needed to make room for. |
Yeah that sounds great. It'll be my first PR to a major project so feedback would be much appreciated once I get the PR done.. |
Yeah, its a bit of a process, and please ping us (and ping us) if it doesn't get attention. |
I created a PR that addresses this in the documentation: #14957 If I don't see any movement in the next few days I'll ping the mailing list? |
You can ping in the pr |
#14957) * Documentation for using ConnectionPatch across Axes with constrained_layout. When using a figure with contrained layout management, adding a ConnectionPatch between different subplot Axes breaks the layout. The artist should be removed from layout considerations before being added to the axes. This commit notes this fix in the documentation. #14907 * Made documentation more general for artist limitations in constrained_layout. * Revised the ConnectionPatch documentation to suggest Figure.add_artist().
Closing as mainly fixed by #14957 |
Bug report
Bug summary
When adding a
ConnectionPatch
that spans multiple axes withconstrained_layout=True
, the layout becomes broken, with the axes getting shrunk considerably. This can be resolved by callingpatch.set_in_layout(False)
before adding the artist to the axes. It may be useful to include a note about this to the documentation forConnectionPatch
.Thanks to ImportanceOfBeingErnest for helping me figure this out on stackoverflow: https://stackoverflow.com/questions/57237711/connectionpatch-breaks-constrained-layout-when-crossing-axes/57241978#57241978
Code for reproduction
I followed the example provided here, except that I changed line 4 to use a managed layout.
Actual outcome
Running the code with constrained_layout produced the following figure:

However, if I add
con.set_in_layout(False)
before theax2.add_artist(con)
on line 26, it produces a nicely layed out figure:Expected outcome
This is the expected figure with
constrained_layout=False
from the example:Matplotlib version
Packages were installed in a conda environment from conda-forge channel.
The text was updated successfully, but these errors were encountered: