Skip to content
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
10 changes: 5 additions & 5 deletions examples/pie_and_polar_charts/bar_of_pie.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import numpy as np

# make figure and assign axis objects
fig = plt.figure(figsize=(9, 5.0625))
fig = plt.figure(figsize=(9, 5))
ax1 = fig.add_subplot(121)
ax2 = fig.add_subplot(122)
fig.subplots_adjust(wspace=0)
Expand Down Expand Up @@ -59,17 +59,17 @@
# draw top connecting line
x = r * np.cos(np.pi / 180 * theta2) + center[0]
y = np.sin(np.pi / 180 * theta2) + center[1]
con = ConnectionPatch(xyA=(- width / 2, bar_height), xyB=(x, y),
coordsA="data", coordsB="data", axesA=ax2, axesB=ax1)
con = ConnectionPatch(xyA=(-width / 2, bar_height), coordsA=ax2.transData,
xyB=(x, y), coordsB=ax1.transData)
con.set_color([0, 0, 0])
con.set_linewidth(4)
ax2.add_artist(con)

# draw bottom connecting line
x = r * np.cos(np.pi / 180 * theta1) + center[0]
y = np.sin(np.pi / 180 * theta1) + center[1]
con = ConnectionPatch(xyA=(- width / 2, 0), xyB=(x, y), coordsA="data",
coordsB="data", axesA=ax2, axesB=ax1)
con = ConnectionPatch(xyA=(-width / 2, 0), coordsA=ax2.transData,
xyB=(x, y), coordsB=ax1.transData)
con.set_color([0, 0, 0])
ax2.add_artist(con)
con.set_linewidth(4)
Expand Down
22 changes: 11 additions & 11 deletions examples/userdemo/connect_simple01.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
A `ConnectionPatch` can be used to draw a line (possibly with arrow head)
between points defined in different coordinate systems and/or axes.
"""

from matplotlib.patches import ConnectionPatch
import matplotlib.pyplot as plt

Expand All @@ -26,21 +27,20 @@
# Draw an arrow between the same point in data coordinates,
# but in different axes.
xy = (0.3, 0.2)
coordsA = "data"
coordsB = "data"
con = ConnectionPatch(xyA=xy, xyB=xy, coordsA=coordsA, coordsB=coordsB,
axesA=ax2, axesB=ax1,
arrowstyle="->", shrinkB=5)
con = ConnectionPatch(
xyA=xy, coordsA=ax2.transData,
xyB=xy, coordsB=ax1.transData,
arrowstyle="->", shrinkB=5)
ax2.add_artist(con)

# Draw a line between the different points, defined in different coordinate
# systems.
xyA = (0.6, 1.0) # in axes coordinates
xyB = (0.0, 0.2) # x in axes coordinates, y in data coordinates
coordsA = "axes fraction"
coordsB = ax2.get_yaxis_transform()
con = ConnectionPatch(xyA=xyA, xyB=xyB, coordsA=coordsA, coordsB=coordsB,
arrowstyle="-")
con = ConnectionPatch(
# in axes coordinates
xyA=(0.6, 1.0), coordsA=ax2.transAxes,
# x in axes coordinates, y in data coordinates
xyB=(0.0, 0.2), coordsB=ax2.get_yaxis_transform(),
arrowstyle="-")
ax2.add_artist(con)

ax1.set_xlim(0, 1)
Expand Down
18 changes: 6 additions & 12 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,12 +548,11 @@ def indicate_inset(self, bounds, inset_ax=None, *, transform=None,
if self.yaxis.get_inverted():
ey = 1 - ey
xy_data = x + ex * width, y + ey * height
p = mpatches.ConnectionPatch(xy_inset_ax, xy_data,
coordsA='axes fraction',
coordsB='data',
axesA=inset_ax, axesB=self,
arrowstyle="-", zorder=zorder,
edgecolor=edgecolor, alpha=alpha)
p = mpatches.ConnectionPatch(
xyA=xy_inset_ax, coordsA=inset_ax.transAxes,
xyB=xy_data, coordsB=self.transData,
arrowstyle="-", zorder=zorder,
edgecolor=edgecolor, alpha=alpha)
connects.append(p)
self.add_patch(p)

Expand Down Expand Up @@ -606,17 +605,12 @@ def indicate_inset_zoom(self, inset_ax, **kwargs):
Two are set with visibility to *False*, but the user can
set the visibility to *True* if the automatic choice is not deemed
correct.

"""

xlim = inset_ax.get_xlim()
ylim = inset_ax.get_ylim()
rect = (xlim[0], ylim[0], xlim[1] - xlim[0], ylim[1] - ylim[0])
rectpatch, connects = self.indicate_inset(
rect, inset_ax, **kwargs
)

return rectpatch, connects
return self.indicate_inset(rect, inset_ax, **kwargs)

@docstring.dedent_interpd
def secondary_xaxis(self, location, *, functions=None, **kwargs):
Expand Down
3 changes: 0 additions & 3 deletions lib/matplotlib/patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -4240,10 +4240,8 @@ def __init__(self, xyA, xyB, coordsA, coordsB=None,
"""
Connect point *xyA* in *coordsA* with point *xyB* in *coordsB*


Valid keys are


=============== ======================================================
Key Description
=============== ======================================================
Expand All @@ -4259,7 +4257,6 @@ def __init__(self, xyA, xyB, coordsA, coordsB=None,
? any key for :class:`matplotlib.patches.PathPatch`
=============== ======================================================


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

Expand Down