김건

5차 구현 사항

...@@ -2,6 +2,9 @@ import downloader ...@@ -2,6 +2,9 @@ import downloader
2 from time import sleep 2 from time import sleep
3 from konlpy.tag import Twitter 3 from konlpy.tag import Twitter
4 from collections import Counter 4 from collections import Counter
5 +from matplotlib import rc
6 +import matplotlib.pyplot as plt
7 +from matplotlib import font_manager as fm
5 import pytagcloud 8 import pytagcloud
6 import operator 9 import operator
7 def get_tags (Comment_List) : 10 def get_tags (Comment_List) :
...@@ -110,9 +113,53 @@ def make_time_chart (Comment_List) : ...@@ -110,9 +113,53 @@ def make_time_chart (Comment_List) :
110 day_data = sorted(day_dict.items(), key=operator.itemgetter(0)) 113 day_data = sorted(day_dict.items(), key=operator.itemgetter(0))
111 hour_data = sorted(hour_dict.items(), key=operator.itemgetter(0)) 114 hour_data = sorted(hour_dict.items(), key=operator.itemgetter(0))
112 minute_data = sorted(minute_dict.items(), key=operator.itemgetter(0)) 115 minute_data = sorted(minute_dict.items(), key=operator.itemgetter(0))
113 - print(month_data) 116 + #print(month_data)
114 - print(week_data) 117 + #print(week_data)
115 - print(day_data) 118 + #print(day_data)
119 + make_chart(year_data,month_data,week_data,day_data,hour_data,minute_data)
120 +
121 +def make_chart(year_data,month_data,week_data,day_data,hour_data,minute_data) :
122 + temp_list = [year_data,month_data,week_data,day_data,hour_data,minute_data]
123 + x_list = []
124 + y_list = []
125 + print(temp_list)
126 + for var1 in temp_list :
127 + for var2 in var1 :
128 + if(var2[0].find('년')>=0):
129 + temp1 = var2[0][0] + 'years'
130 + temp2 = int(var2[1])
131 + x_list.append(temp1)
132 + y_list.append(temp2)
133 + elif(var2[0].find('개월')>=0):
134 + temp1 = var2[0][0] + 'months'
135 + temp2 = int(var2[1])
136 + x_list.append(temp1)
137 + y_list.append(temp2)
138 + elif(var2[0].find('주')>=0):
139 + temp1 = var2[0][0] + 'weeks'
140 + temp2 = int(var2[1])
141 + x_list.append(temp1)
142 + y_list.append(temp2)
143 + elif(var2[0].find('일')>=0):
144 + temp1 = var2[0][0] + 'days'
145 + temp2 = int(var2[1])
146 + x_list.append(temp1)
147 + y_list.append(temp2)
148 + elif(var2[0].find('시간')>=0):
149 + temp1 = var2[0][0] + 'hours'
150 + temp2 = int(var2[1])
151 + x_list.append(temp1)
152 + y_list.append(temp2)
153 + else:
154 + temp1 = var2[0][0] + 'minutes'
155 + temp2 = int(var2[1])
156 + x_list.append(temp1)
157 + y_list.append(temp2)
158 + print(x_list)
159 + plt.bar(x_list,y_list,width = 0.5 , color = "blue")
160 + # plt.show() -> 출력
161 + plt.savefig('chart.png',dpi=300)
162 + # plt.savefig('chart.png', dpi=300)
116 163
117 def call_main (): 164 def call_main ():
118 print(' Comment Thread 생성중 \n') 165 print(' Comment Thread 생성중 \n')
......
...@@ -8,3 +8,4 @@ pytagcloud ...@@ -8,3 +8,4 @@ pytagcloud
8 ### wordcloud 8 ### wordcloud
9 Jpye1 9 Jpye1
10 ### Ű м 10 ### Ű м
11 +python -m pip install -U matplotlib==3.2.0rc1
......
...@@ -46,3 +46,7 @@ Youtube 3차 수정 사항 ...@@ -46,3 +46,7 @@ Youtube 3차 수정 사항
46 46
47 1. 시간대 별로 sort된 리스트를 matplotlib python을 이용하여 차트화 시키기 47 1. 시간대 별로 sort된 리스트를 matplotlib python을 이용하여 차트화 시키기
48 2. 기능 별로 접근할 수 있도록 정리할 것 48 2. 기능 별로 접근할 수 있도록 정리할 것
49 +-----------------------------------------------------
50 +5차 개발사항
51 +
52 +1. 시간대 별로 sort된 리스트를 matplotlib for python을 이용하여 차트화 하였음
...\ No newline at end of file ...\ No newline at end of file
......