https://matplotlib.org/
Untitled
π μ°¨νΈ μ ν
- μ κ·Έλν(
Line Plot): λ°μ΄ν°μ λ³νλ₯Ό μ μΌλ‘ μ°κ²°νμ¬ μκ°νν©λλ€.
- λ§λ κ·Έλν(
Bar Chart): λ²μ£Όν λ°μ΄ν°μ κ°μ λ§λλ‘ ννν©λλ€.
- https://matplotlib.org/stable/gallery/lines_bars_and_markers/barchart.html#sphx-glr-gallery-lines-bars-and-markers-barchart-py
- https://matplotlib.org/stable/gallery/lines_bars_and_markers/barh.html
- νμ€ν κ·Έλ¨(
Histogram): μ°μν λ°μ΄ν°μ λΆν¬λ₯Ό ꡬκ°λ³λ‘ λ§λλ‘ λνλ
λλ€.
- https://matplotlib.org/stable/gallery/statistics/hist.html
- https://matplotlib.org/stable/gallery/mplot3d/hist3d.html
- https://numpy.org/doc/stable/reference/generated/numpy.histogram.html#numpy.histogram
- μ°μ λ(
Scatter Plot): λ λ³μμ κ΄κ³λ₯Ό μ μΌλ‘ ννν©λλ€.
- νμ΄ μ°¨νΈ(
Pie Chart): μ 체 λλΉ κ° λΆλΆμ λΉμ¨μ μνμΌλ‘ λνλ
λλ€.
- λ°μ€νλ‘―(
Box Plot): λ°μ΄ν°μ λΆν¬μ μ΄μμΉλ₯Ό μκ°νν©λλ€.
- μμ κ·Έλν(
Area Plot): μ κ·Έλν μλ μμμ μ±μμ ννν©λλ€.
- ννΈλ§΅(
Heatmap): κ°μ ν¬κΈ°λ₯Ό μμμΌλ‘ νννλ 2μ°¨μ κ·Έλνμ
λλ€.
π§βπ» μ€ λ°μ΄ν°λ₯Ό μ΄μ©ν μ°¨νΈ(Histograms) 그리기
.csv νμΌμ λ°μ΄ν° νμ©νκΈ°

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt # chart 그리기
import matplotlib.font_manager as fm # font μ€μ
######## νκΈ ν°νΈ μ¬μ©μ μν μ€μ ########
font_path = "C:/Windows/Fonts/gulim.ttc" # μ¬μ©ν νκΈ ν°νΈ κ²½λ‘
font_prop = fm.FontProperties(fname=font_path, size=12) # ν°νΈ μμ± κ°μ²΄ μμ±
plt.rcParams['axes.unicode_minus'] = False # λ§μ΄λμ€ κΈ°νΈ
plt.rcParams['font.family'] = font_prop.get_name() # matplotlib μ μ ν°νΈ μ€μ
########## μνΈνν μΌμΌ μμ΅λ₯ νμ€ν κ·Έλ¨ ##########
# - BTC : λΉνΈμ½μΈ
# - ETH : μ΄λ리μ
# - LTC : λΌμ΄νΈμ½μΈ
# - μΌμΌ μμ΅λ₯ : (μ€λ μ’
κ° - μ΄μ μ’
κ°) / μ΄μ μ’
κ° * 100
# .csv νμΌ λΆλ¬μ€κΈ°
df = pd.read_csv('./data/crypto_daily_returns.csv')
# λΉνΈ `μ½μΈ`κ³Ό `μ΄λ리μ` κ·Έλν 그리기
plt.hist(df['BTC'], bins=30, alpha=0.5, label='BTC')
plt.hist(df['ETH'], bins=30, alpha=0.5, label='ETH')
plt.xlabel('Daily Returns')
plt.ylabel('Frequency')
plt.title('μνΈνν μΌμΌ μμ΅λ₯ ')
plt.legend()
plt.show()
