Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Documentation for using ConnectionPatch across Axes with constrained_… #14957

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 3 commits into from
Aug 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions lib/matplotlib/patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -4229,8 +4229,7 @@ def __init__(self, xyA, xyB, coordsA, coordsB=None,
clip_on=False,
dpi_cor=1.,
**kwargs):
"""
Connect point *xyA* in *coordsA* with point *xyB* in *coordsB*
"""Connect point *xyA* in *coordsA* with point *xyB* in *coordsB*

Valid keys are

Expand Down Expand Up @@ -4273,6 +4272,22 @@ def __init__(self, xyA, xyB, coordsA, coordsB=None,

Alternatively they can be set to any valid
`~matplotlib.transforms.Transform`.

.. note::

Using :class:`~matplotlib.patches.ConnectionPatch` across
two :class:`~matplotlib.axes.Axes` instances is not
directly compatible with :doc:`constrained layout
</tutorials/intermediate/constrainedlayout_guide>`. Add the
artist directly to the :class:`~matplotlib.figure.Figure`
instead of adding it to a specific Axes.

.. code-block:: default

fig, ax = plt.subplots(1, 2, constrained_layout=True)
con = ConnectionPatch(..., axesA=ax[0], axesB=ax[1])
fig.add_artist(con)

"""
if coordsB is None:
coordsB = coordsA
Expand Down
7 changes: 7 additions & 0 deletions tutorials/intermediate/constrainedlayout_guide.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,13 @@ def docomplicated(suptitle=None):
#
# * There are small differences in how the backends handle rendering fonts,
# so the results will not be pixel-identical.
#
# * An artist using axes coordinates that extend beyond the axes
# boundary will result in unusual layouts when added to an
# axes. This can be avoided by adding the artist directly to the
# :class:`~matplotlib.figure.Figure` using
# :meth:`~matplotlib.figure.Figure.add_artist`. See
# :class:`~matplotlib.patches.ConnectionPatch` for an example.

###########################################################
# Debugging
Expand Down