Skip to content

In docs, add multi-axes connectionpatches to Figure, not Axes. #16658

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 4, 2020
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
2 changes: 1 addition & 1 deletion examples/userdemo/connect_simple01.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
xyA=xy, coordsA=ax2.transData,
xyB=xy, coordsB=ax1.transData,
arrowstyle="->", shrinkB=5)
ax2.add_artist(con)
fig.add_artist(con)

# Draw a line between the different points, defined in different coordinate
# systems.
Expand Down
15 changes: 8 additions & 7 deletions tutorials/text/annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,15 +499,15 @@
Using ConnectionPatch
~~~~~~~~~~~~~~~~~~~~~

The ConnectionPatch is like an annotation without text. While the annotate
function is recommended in most situations, the ConnectionPatch is useful when
you want to connect points in different axes. ::
ConnectionPatch is like an annotation without text. While `~.Axes.annotate`
is sufficient in most situations, ConnectionPatch is useful when you want to
connect points in different axes. ::

from matplotlib.patches import ConnectionPatch
xy = (0.2, 0.2)
con = ConnectionPatch(xyA=xy, coordsA=ax1.transData,
xyB=xy, coordsB=ax2.transData)
ax2.add_artist(con)
fig.add_artist(con)

The above code connects point *xy* in the data coordinates of ``ax1`` to
point *xy* in the data coordinates of ``ax2``. Here is a simple example.
Expand All @@ -519,9 +519,10 @@

Connect Simple01

While the ConnectionPatch instance can be added to any axes, you may want to
add it to the axes that is drawn last, to prevent it from being covered by
other axes.
Here, we added the ConnectionPatch to the *figure* (with `~.Figure.add_artist`)
rather than to either axes: this ensures that it is drawn on top of both axes,
and is also necessary if using :doc:`constrained_layout
</tutorials/intermediate/constrainedlayout_guide>` for positioning the axes.

Advanced Topics
---------------
Expand Down