Description
Bug report
Bug summary
When adding a ConnectionPatch
that spans multiple axes with constrained_layout=True
, the layout becomes broken, with the axes getting shrunk considerably. This can be resolved by calling patch.set_in_layout(False)
before adding the artist to the axes. It may be useful to include a note about this to the documentation for ConnectionPatch
.
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.
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(6, 3), constrained_layout=True)
Actual outcome
Running the code with constrained_layout produced the following figure:
However, if I add con.set_in_layout(False)
before the ax2.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
- Operating system: Linux, Gentoo 2.6
- Matplotlib version: 3.1.1
- Matplotlib backend: module://ipykernel.pylab.backend_inline
- Python version: 3.6.7
- Jupyter version (if applicable): 5.2.3
- Other libraries:
Packages were installed in a conda environment from conda-forge channel.