수업정리/Data Visualization

[중간대비] (Week2 - Week3) 이론 정리

GreenBNN 2024. 4. 12. 16:28

https://docs.google.com/presentation/d/1WuslABTUkVq30rgyDWhGJmKxM9sKQ4EUCnzVZmsAS6Q/edit#slide=id.g2c1f168417e_0_0

Google Colab and Jupyter Notebooks 사용 : interactive environments for writing and running code

Feature Jupyter Notebooks Google Colab
Hosting Can be run locally or on a server Hosted in the cloud
Access to Resources Requires own hardware or cloud setup Free access to GPUs and TPUs
Collaboration Sharing requires tools like GitHub Easy sharing and collaboration like Google Suite
Customizability and Control High control over environment and libraries Easier setup, less customization control

Matplotlib : creating static, interactive and anumbated visualizations in Python

Numpy Library : 배열 연산? 데이터 범위 연산에 사용

range(5) = [0,1,2,3,4] 를 만드는데 막대 그래프에서 각 막대 위치를 소수점으로 옮기려면

offset을 더하고 뺴야하는데 range로 만든 리스트는 정수만 가능해서 불가능하다

여기서 numpy의 arange() 함수가 유용히 사용된다.

(예시) plt.bar

import numpy as np
import matplotlib.pyplot as plt

years= [1965,1975, 1985, 1995, 2005, 2015]
ko= [130,650,2450,11600,17790,27250]
jp= [890, 5120,11500,42130,40560,38780]
ch= [100,200,290,540,1760,7940]


# 기준이 되는 점 만들고 / 소수 -+ 가능하게 하기
x_range= np.arange(len(years))    # years의 길이만큼 소수점 단위도 가능한 범위 생성. check ppt's 6th page
plt.xticks(range(len(years)),years) # x 축을 원소들로 입력해줘야함

plt.bar(x_range+0.0,ko,width=0.25)
plt.bar(x_range+0.3,jp,width=0.25)
plt.bar(x_range+0.6,ch,width=0.25)

plt.show()


ppt Page 7 부터 ~~