본문 바로가기
파이썬

[Python] Matplotlib 소개 및 예시

by 책 읽는 개발자_테드 2020. 6. 2.
반응형

Matplotlib는 Python에서 정적, 동적 그리고 상호적인 시각자료를 작성하기위한 포괄적인 라이브러리입니다.

 

scatter

scatter 함수는 하나의 변수가 다른 변수의 영향을 받는 정도를 보여주기 위해 가로 및 세로 축에 데이터 요소를 표시하는 데 사용됩니다. 

 

예시

import numpy as np
import matplotlib.pyplot as plt
N = 500
X = 2*np.random.rand(500,1)
y = 4 + 3*X + np.random.rand(500,1)
plt.scatter(X,y)

 

figure

figure 함수는 지정된 비율로 figure의 너비와 높이를 계산합니다. 여기서 나온 figure는 matplotlib의 figure 클래스를 말하며, 모든 plot 요소의 최상위 컨테이너입니다.

 

title

title 함수를 통해 plot의 제목을 지정합니다.

 

 

xlabel 과 ylabel 

다음 함수들로 plot의 x, y 축 레이블을 지정합니다.

 

예시

import numpy as np
import matplotlib.pyplot as plt
N = 500
X = 2*np.random.rand(500,1)
y = 4 + 3*X + np.random.rand(500,1)

plt.figure(figsize=(10,10))
plt.scatter(X,y)
plt.title("Linear Regression Data")
plt.xlabel("x")
plt.ylabel("y")

 

깃헙 주소

https://github.com/matplotlib/matplotlib

 

공식홈페이지

https://matplotlib.org/https://ko.wikipedia.org/wiki/Matplotlib

 

 

출처

공식홈페이지

tutorialspoint

반응형

댓글