본문 바로가기
카테고리 없음

06. 텍스트

by _션샤인 2024. 6. 26.
import matplotlib.pyplot as plt
import matplotlib
matplotlib.rcParams['font.family'] = 'Malgun Gothic'
matplotlib.rcParams['font.size'] = 15
matplotlib.rcParams['axes.unicode_minus'] = False
x = [1, 2, 3]
y = [2, 4, 8]
plt.plot(x, y)

-

plt.plot(x,y, marker='o')

for idx, txt in enumerate(y):
    plt.text(x[idx], y[idx], txt)

x[idx], y[idx], txt = x 인덱스, y인덱스 값을 텍스트로 입력하겠다

plt.plot(x,y, marker='o')

for idx, txt in enumerate(y):
    plt.text(x[idx], y[idx]+0.3, txt, ha='center', color='blue')

x[idx], y[idx]+0.3, txt = y 축으로 0.3 만큼 올리겠음, ha='center' (마커 중앙에 위치) color='blue'( 컬러는 블루)