인프런 - 강의/청와대 청원 데이터 시각화

11 - Data 시각화하기

개복치 개발자 2020. 3. 2. 05:00

 

# Package 넣어줌
import numpy as np
import matplotlib.pyplot as plt


# 값 입력
label = ['A', 'B', 'C', 'S']
index = np.arange(len(label))
plt.bar(index, [10,5,20,10])

# 그리기
plt.title('My title')
plt.xlabel('X-title')
plt.ylabel('Y-title')
plt.xticks(index, label)

plt.show()

list_data = [('코로나', 29),
 ('재인', 18),
 ('대통령', 18),
 ('신천지', 18),
 ('문재인', 16),
 ('마스크', 16),
 ('탄핵', 15),
 ('청원', 14),
 ('코로나19', 13),
 ('19', 13),
 ('촉구', 10),
 ('지원', 10),
 ('요청', 9),
 ('반대', 9),
 ('대구', 9),
 ('정부', 8),
 ('개학', 7),
 ('폐렴', 7),
 ('중국', 6),
 ('국민', 6)]
 
list_string = []
list_number = []

for s,n in list_data :
    print(s, n)
    list_string.append(s)
    list_number.append(n)
    
list_string

label = list_string
index = np.arange(len(label))
plt.bar(index, list_number)

# 그리기
plt.title('text-show')
plt.xlabel('string')
plt.ylabel('number')
plt.xticks(index, label)

plt.show()

label = list_string
index = np.arange(len(label))
plt.bar(index, list_number)

# 그리기
plt.title('text-show')
plt.xlabel('string')
plt.ylabel('number')
plt.xticks(index, label)
plt.xticks(rotation = 45 )

plt.show()


# 한글이 안된다면?
# https://programmers.co.kr/learn/courses/21/lessons/950
# https://www.youtube.com/watch?v=XfLZH7-1pcM
# https://financedata.github.io/posts/matplotlib-hangul-for-windows-anaconda.html