고급 quiver 및 quiverkey 기능 #

에 대한 몇 가지 고급 옵션을 보여줍니다 quiver. 간단한 예는 Quiver 단순 데모 를 참조하십시오 .

참고: 플롯 자동 크기 조정은 화살표를 고려하지 않으므로 경계에 있는 화살표가 그림 밖으로 나올 수 있습니다. 이것은 완벽하게 일반적인 방법으로 해결하기 쉬운 문제가 아닙니다. 권장되는 해결 방법은 이러한 경우 축 제한을 수동으로 설정하는 것입니다.

import matplotlib.pyplot as plt
import numpy as np

X, Y = np.meshgrid(np.arange(0, 2 * np.pi, .2), np.arange(0, 2 * np.pi, .2))
U = np.cos(X)
V = np.sin(Y)
fig1, ax1 = plt.subplots()
ax1.set_title('Arrows scale with plot width, not view')
Q = ax1.quiver(X, Y, U, V, units='width')
qk = ax1.quiverkey(Q, 0.9, 0.9, 2, r'$2 \frac{m}{s}$', labelpos='E',
                   coordinates='figure')
화살표는 보기가 아닌 플롯 너비로 축척됩니다.
fig2, ax2 = plt.subplots()
ax2.set_title("pivot='mid'; every third arrow; units='inches'")
Q = ax2.quiver(X[::3, ::3], Y[::3, ::3], U[::3, ::3], V[::3, ::3],
               pivot='mid', units='inches')
qk = ax2.quiverkey(Q, 0.9, 0.9, 1, r'$1 \frac{m}{s}$', labelpos='E',
                   coordinates='figure')
ax2.scatter(X[::3, ::3], Y[::3, ::3], color='r', s=5)
피벗='중간';  세 번째 화살표마다;  단위='인치'
<matplotlib.collections.PathCollection object at 0x7f2cfad10ac0>
fig3, ax3 = plt.subplots()
ax3.set_title("pivot='tip'; scales with x view")
M = np.hypot(U, V)
Q = ax3.quiver(X, Y, U, V, M, units='x', pivot='tip', width=0.022,
               scale=1 / 0.15)
qk = ax3.quiverkey(Q, 0.9, 0.9, 1, r'$1 \frac{m}{s}$', labelpos='E',
                   coordinates='figure')
ax3.scatter(X, Y, color='0.5', s=1)

plt.show()
피벗='팁';  x 보기로 확장

참조

다음 함수, 메서드, 클래스 및 모듈의 사용이 이 예제에 표시됩니다.

스크립트의 총 실행 시간: ( 0분 1.864초)

Sphinx-Gallery에서 생성한 갤러리