Jupyter Notebook을 통한 Matplotlib 시작

gaebokchi·2021년 2월 4일
0

데이터분석

목록 보기
4/5

Matplotlib공식문서

%matplotlib inline # matplolib 쓰려면 이 줄이 꼭 필요
import matplotlib.pyplot as plt

# 이전 pandas로 만들었던 데이터포맷 df에는 Names와 Births 필드가 있다 각 필드를 x,y축으로 설정
y = df['Births']
x = df['Names']

# bar plot 출력
plt.bar(x,y) # 막대그래프 객체 생성
plt.xlabel('Names') # x축 제목
plt.ylabel('Births') # y축 제목
plt.title('Bar plot') # 그래프 제목
plt.show() # 그래프 출력

# 랜덤 추출 시드 고정
np.random.seed(19920613)

# scatooer plot 데이터를 생성
x = np. arrange(0.0, 100.0, 5.0)
y = (x * 1.5) + np.random.rand(20) * 50

# scatter plot 출력
plt.scatter(x,y, c="b", alpha=0.5, label="scatter point")
plt.xlabel("X") # 
plt.ylabel("Y")
plt.legent(loc='upper left')
plt.title('Scatter plot')
plt.show() # 그래프 출력

0개의 댓글