티스토리 뷰

histogram

  • 빈도 분포를 표현하고자할 때, 히스토그램 그래프가 시각적으로 효과적임
  • plt.hist
    • x : 발생빈도가 있는 값
    • bins : 가로축 구간의 개수
      • bins vs. xticks
    • density : yticks 를 퍼센트 비율료 표현 여부
    • orientiation : vertical or horizontal
    • histtype : 히스토그램 종류
      • bar (default)
      • barstacked
      • step
      • stepfilled
    • cumulative : 누적 히스토그램 여부

 

x = [x for x in range(1, 11) if x%2==0]
x = x*2
plt.hist(x, edgecolor='black', width=0.5)
plt.yticks(np.linspace(0, 2, 3))
plt.show()

 

 

 

 

 

 

 

 

scatter (산점도)

  • 두 데이터 집합의 상관관계를 확인할 때, 시각적으로 효율적임
  • plt.scatter(x, y)
    • size : 마커의 크기
    • color : 마커의 색상. 데이터 길이와 같은 크기의 숫자 시퀀스/rgb/ Hex xode
    • alpah : xnaudeh
    • cmap : 컬러맵

 

colors = np.random.rand(50)
area = np.random.rand(50)*500
x = np.random.rand(50)
y = np.random.rand(50)

plt.scatter(x, y, sizes=area, c=colors, alpha=0.5)
plt.show()

 

 

 

imshow (이미지 그래프)

  • 이미지 데이터 : 픽셀의 모음이 행과 열을 가진 2차원 데이터
  • plt.imshow(2차원 픽셀 데이터)

 

from sklearn.datasets import load_digits
digits = load_digits()
x = digits.images[9]
plt.imshow(x)
plt.show()

 

 

 

 

 

 

 

댓글