Matplotlib-quiver-plot

提供:Dev Guides
移動先:案内検索

Matplotlib-矢筒プロット

矢筒プロットは、点(x、y)に成分(u、v)を持つ矢印として速度ベクトルを表示します。

quiver(x,y,u,v)

上記のコマンドは、xおよびyの対応する要素の各ペアで指定された座標に矢印としてベクトルをプロットします。

パラメーター

次の表は、Quiverプロットのさまざまなパラメータを示しています-

x 1D or 2D array, sequence. The x coordinates of the arrow locations
y 1D or 2D array, sequence. The y coordinates of the arrow locations
u 1D or 2D array, sequence. The x components of the arrow vectors
v 1D or 2D array, sequence. The y components of the arrow vectors
c 1D or 2D array, sequence. The arrow colors

次のコードは、単純な矢筒プロットを描きます-

import matplotlib.pyplot as plt
import numpy as np
x,y = np.meshgrid(np.arange(-2, 2, .2), np.arange(-2, 2, .25))
z = x*np.exp(-x**2 - y**2)
v, u = np.gradient(z, .2, .2)
fig, ax = plt.subplots()
q = ax.quiver(x,y,u,v)
plt.show()

クイックプロット