# matplotlib.patches.ConnectionPatch¶

class matplotlib.patches.ConnectionPatch(xyA, xyB, coordsA, coordsB=None, axesA=None, axesB=None, arrowstyle='-', connectionstyle='arc3', patchA=None, patchB=None, shrinkA=0.0, shrinkB=0.0, mutation_scale=10.0, mutation_aspect=None, clip_on=False, dpi_cor=1.0, **kwargs)[source]

A patch that connects two points (possibly in different axes).

Connect point xyA in coordsA with point xyB in coordsB.

Valid keys are

Key Description
arrowstyle the arrow style
connectionstyle the connection style
relpos default is (0.5, 0.5)
patchA default is bounding box of the text
patchB default is None
shrinkA default is 2 points
shrinkB default is 2 points
mutation_scale default is text size (in points)
mutation_aspect default is 1.
? any key for matplotlib.patches.PathPatch

coordsA and coordsB are strings that indicate the coordinates of xyA and xyB.

Property Description
'figure points' points from the lower left corner of the figure
'figure pixels' pixels from the lower left corner of the figure
'figure fraction' 0, 0 is lower left of figure and 1, 1 is upper right
'axes points' points from lower left corner of axes
'axes pixels' pixels from lower left corner of axes
'axes fraction' 0, 0 is lower left of axes and 1, 1 is upper right
'data' use the coordinate system of the object being annotated (default)
'offset points' offset (in points) from the xy value
'polar' you can specify theta, r for the annotation, even in cartesian plots. Note that if you are using a polar axes, you do not need to specify polar for the coordinate system since that is the native "data" coordinate system.

Alternatively they can be set to any valid Transform.

Note

Using ConnectionPatch across two Axes instances is not directly compatible with constrained layout. Add the artist directly to the Figure instead of adding it to a specific Axes.

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

__init__(self, xyA, xyB, coordsA, coordsB=None, axesA=None, axesB=None, arrowstyle='-', connectionstyle='arc3', patchA=None, patchB=None, shrinkA=0.0, shrinkB=0.0, mutation_scale=10.0, mutation_aspect=None, clip_on=False, dpi_cor=1.0, **kwargs)[source]

Connect point xyA in coordsA with point xyB in coordsB.

Valid keys are

Key Description
arrowstyle the arrow style
connectionstyle the connection style
relpos default is (0.5, 0.5)
patchA default is bounding box of the text
patchB default is None
shrinkA default is 2 points
shrinkB default is 2 points
mutation_scale default is text size (in points)
mutation_aspect default is 1.
? any key for matplotlib.patches.PathPatch

coordsA and coordsB are strings that indicate the coordinates of xyA and xyB.

Property Description
'figure points' points from the lower left corner of the figure
'figure pixels' pixels from the lower left corner of the figure
'figure fraction' 0, 0 is lower left of figure and 1, 1 is upper right
'axes points' points from lower left corner of axes
'axes pixels' pixels from lower left corner of axes
'axes fraction' 0, 0 is lower left of axes and 1, 1 is upper right
'data' use the coordinate system of the object being annotated (default)
'offset points' offset (in points) from the xy value
'polar' you can specify theta, r for the annotation, even in cartesian plots. Note that if you are using a polar axes, you do not need to specify polar for the coordinate system since that is the native "data" coordinate system.

Alternatively they can be set to any valid Transform.

Note

Using ConnectionPatch across two Axes instances is not directly compatible with constrained layout. Add the artist directly to the Figure instead of adding it to a specific Axes.

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

__module__ = 'matplotlib.patches'
__str__(self)[source]

Return str(self).

draw(self, renderer)[source]

Draw the Artist (and its children) using the given renderer.

This has no effect if the artist is not visible (Artist.get_visible returns False).

Parameters: rendererRendererBase subclass.

Notes

This method is overridden in the Artist subclasses.

get_annotation_clip(self)[source]

Return the clipping behavior.

See set_annotation_clip for the meaning of the return value.

get_path_in_displaycoord(self)[source]

Return the mutated path of the arrow in display coordinates.

set_annotation_clip(self, b)[source]

Set the clipping behavior.

Parameters: bbool or None False: The annotation will always be drawn regardless of its position. True: The annotation will only be drawn if self.xy is inside the axes. None: The annotation will only be drawn if self.xy is inside the axes and self.xycoords == "data".