# 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
'인프런 - 강의 > 청와대 청원 데이터 시각화' 카테고리의 다른 글
13 - wordcloud 한글, 그림 (4) | 2020.03.05 |
---|---|
12 - wordcloud 그림그리기 (0) | 2020.03.04 |
10 - 실제 데이터 가공하기 (0) | 2020.03.02 |
9 - 텍스트 가공하기 (0) | 2020.03.02 |
8 - 단어 숫자 세기 (0) | 2020.03.02 |