메모
전체 예제 코드를 다운로드 하려면 여기 를 클릭 하십시오.
Simple01 연결 #
A ConnectionPatch
는 서로 다른 좌표계 및/또는 축에 정의된 점 사이에 선을 그리는 데 사용할 수 있습니다(화살표가 있을 수 있음).
![심플01 연결](/stable/_images/sphx_glr_connect_simple01_001.png)
from matplotlib.patches import ConnectionPatch
import matplotlib.pyplot as plt
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(6, 3))
# Draw a simple arrow between two points in axes coordinates
# within a single axes.
xyA = (0.2, 0.2)
xyB = (0.8, 0.8)
coordsA = "data"
coordsB = "data"
con = ConnectionPatch(xyA, xyB, coordsA, coordsB,
arrowstyle="-|>", shrinkA=5, shrinkB=5,
mutation_scale=20, fc="w")
ax1.plot([xyA[0], xyB[0]], [xyA[1], xyB[1]], "o")
ax1.add_artist(con)
# Draw an arrow between the same point in data coordinates,
# but in different axes.
xy = (0.3, 0.2)
con = ConnectionPatch(
xyA=xy, coordsA=ax2.transData,
xyB=xy, coordsB=ax1.transData,
arrowstyle="->", shrinkB=5)
fig.add_artist(con)
# Draw a line between the different points, defined in different coordinate
# systems.
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)
ax1.set_ylim(0, 1)
ax2.set_xlim(0, .5)
ax2.set_ylim(0, .5)
plt.show()