各種ライブラリ読み込み

In [1]:
%pylab inline
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
Populating the interactive namespace from numpy and matplotlib

方向と長さが変わる場合の図

In [2]:
x_min = -1
x_max = 20
y_min = -1
y_max = 20
plt.axis([x_min, x_max, y_min, y_max])

#描画範囲の面積を基準に、程よいarrowの幅を生成
area = ((x_max - x_min) ** 2 + (y_max - y_min) ** 2) ** 0.5
characteristic_length = area ** 0.5
ar_width =  characteristic_length * 0.03
ar_head_width = ar_width * 3.0

#arrowを指定
#before
plt.arrow(0., 0., 5., 1.,
          width = ar_width, head_width = ar_head_width, length_includes_head = True, 
          color = "b")
#after
plt.arrow(0., 0., 16., 14,
          width = ar_width, head_width = ar_head_width, length_includes_head = True, 
          color = "r")
plt.show()

方向が変わらない場合の図

In [3]:
x_min = -1
x_max = 8
y_min = -1
y_max = 14
plt.axis([x_min, x_max, y_min, y_max])

#描画範囲の面積を基準に、程よいarrowの幅を生成
area = ((x_max - x_min) ** 2 + (y_max - y_min) ** 2) ** 0.5
characteristic_length = area ** 0.5
ar_width =  characteristic_length * 0.03
ar_head_width = ar_width * 3.0

#arrowを指定
#before
plt.arrow(0., 0., 1., 2.,
          width = ar_width, head_width = ar_head_width, length_includes_head = True, 
          color = "b")
#after
plt.arrow(0., 0.+0.1, 5., 10+0.1,
          width = ar_width, head_width = ar_head_width, length_includes_head = True, 
          color = "r")
plt.show()