2020年5月27日水曜日

数学 - Pytyhon - 解析学 - ベクトル - 空間の点の定義 - 2つのベクトル、差、グラフ

コード

#!/usr/bin/env python3
from sympy import symbols, Matrix
from sympy.plotting import plot_parametric

print('9.')

t = symbols('t')
AS = [Matrix([a, b]) for a, b in [(1, 2),
(3, 1),
(1, 1),
(2, 2)]]
BS = [Matrix([a, b]) for a, b in [(2, 1),
(1, 3),
(-2, 2),
(3, -2)]]
CS = [A - B for A, B in zip(AS, BS)]

t = symbols('t')
p = plot_parametric(*[(*(t * v), (t, 0, 1)) for v in AS + BS + CS],
*[(*(v + t * w), (t, 0, 1)) for v, w in zip(BS, CS)],
xlim=(-5, 5),
ylim=(-5, 5),
legend=False,
show=False)
colors = ['red', 'green', 'blue', 'brown', 'orange',
'purple', 'pink', 'gray', 'skyblue', 'yellow']

for o, color in zip(p, colors):
o.line_color = color
p.show()
p.save('sample9.png')


% ./sample9.py
9.
/opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/sympy/plotting/plot.py:1065: MatplotlibDeprecationWarning:
The set_smart_bounds function was deprecated in Matplotlib 3.2 and will be removed two minor releases later.
self.ax[i].spines['left'].set_smart_bounds(True)
/opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/sympy/plotting/plot.py:1066: MatplotlibDeprecationWarning:
The set_smart_bounds function was deprecated in Matplotlib 3.2 and will be removed two minor releases later.
self.ax[i].spines['bottom'].set_smart_bounds(False)
%