라이브러리 불러오기
import numpy as np
import matplotlib.pyplot as plt
# 행렬과 벡터를 위해 numpy 불러오기
# 벡터 시각화를 위해 pylot 불러오기
pyplot의 subplots 시각화 함수로 "x,y축, 라벨, 범례, 그리드활성" 만들기
# 시각화
fig, axs = plt.subplots()
# 그리드를 생성합니다.
x_vals = np.linspace(0, 2, 5) # -5에서 5 사이의 11개의 점 (축과 맞추기 위함)
y_vals = np.linspace(0, 2, 5) # -5에서 5 사이의 11개의 점 (축과 맞추기 위함)
X, Y = np.meshgrid(x_vals, y_vals)
# 벡터 1, 2
axs.arrow(0, 0, 1.9, 1.9, head_width=0.1, head_length=0.1, fc='pink', ec='pink')
axs.arrow(0, 0, 1.9, 0.9, head_width=0.1, head_length=0.1, fc='red', ec='red')
axs.plot(X, Y, color="brown", alpha=0.5, linestyle="--", label='limit x',lw=1) # 시작점(x,0) # alpha는 투명도
axs.plot(X.T, Y.T, color="orange", linestyle="--", label='limit y',lw=1) # 시작점(0,y)
# 축 설정
axs.set_xlim(0, 3) # x축 범위
axs.set_ylim(0, 3) # y축 범위
# 축 라벨과 그리드 추가
axs.set_xlabel('X-axis')
axs.set_ylabel('Y-axis')
axs.grid(True) # True = 그리드 추가함 , False = 추가 안함
plt.show()