본문 바로가기
Data Science/파이썬 기본문법

[파이썬] matplotlib 기본 그리기 연습

by titaniumm 2020. 4. 22.

익숙해질때까지~

import numpy as np
import matplotlib.pyplot as plt

#간단한 그래프 그리기
x = np.arange(0,6,0.1)
y = np.sin(x)

plt.plot(x,y)
plt.show()

x = np.arange(0,10,0.1)
y = np.sin(x)

plt.plot(x,y)
plt.show()


#pyplot
x = np.arange(0,6,0.1)
y1 = np.sin(x)
y2 = np.cos(x)

plt.plot(x,y1,label='sin')
plt.plot(x,y2,linestyle="--",label = "cos") #점선
plt.xlabel("x")
plt.ylabel("y")
plt.title("sin & cos")
plt.legend() #왼쪽 밑의 설명 표시
plt.show()

댓글