PinkWink / DataScience

책) 파이썬으로 데이터 주무르기 - 소스코드 및 데이터 공개
http://pinkwink.kr/1070
243 stars 503 forks source link

71pg plt.text 부분에서 알 수 없는 ValueError가 뜹니다. #56

Open ploffer11 opened 5 years ago

ploffer11 commented 5 years ago

image

책에 있는 코드를 그대로 타이핑 했는데


ValueError Traceback (most recent call last) ~\Anaconda3\envs\py36\lib\site-packages\IPython\core\formatters.py in call(self, obj) 339 pass 340 else: --> 341 return printer(obj) 342 # Finally look for special method names 343 method = get_real_method(obj, self.print_method)

~\Anaconda3\envs\py36\lib\site-packages\IPython\core\pylabtools.py in (fig) 242 243 if 'png' in formats: --> 244 png_formatter.for_type(Figure, lambda fig: print_figure(fig, 'png', kwargs)) 245 if 'retina' in formats or 'png2x' in formats: 246 png_formatter.for_type(Figure, lambda fig: retina_figure(fig, kwargs))

~\Anaconda3\envs\py36\lib\site-packages\IPython\core\pylabtools.py in print_figure(fig, fmt, bbox_inches, kwargs) 126 127 bytes_io = BytesIO() --> 128 fig.canvas.print_figure(bytes_io, kw) 129 data = bytes_io.getvalue() 130 if fmt == 'svg':

~\AppData\Roaming\Python\Python36\site-packages\matplotlib\backend_bases.py in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, kwargs) 2257 orientation=orientation, 2258 bbox_inches_restore=_bbox_inches_restore, -> 2259 kwargs) 2260 finally: 2261 if bbox_inches and restore_bbox:

~\AppData\Roaming\Python\Python36\site-packages\matplotlib\backends\backend_agg.py in print_png(self, filename_or_obj, *args, *kwargs) 505 506 def print_png(self, filename_or_obj, args, **kwargs): --> 507 FigureCanvasAgg.draw(self) 508 renderer = self.get_renderer() 509 original_dpi = renderer.dpi

~\AppData\Roaming\Python\Python36\site-packages\matplotlib\backends\backend_agg.py in draw(self) 420 Draw the figure using the renderer 421 """ --> 422 self.renderer = self.get_renderer(cleared=True) 423 # acquire a lock on the shared font cache 424 RendererAgg.lock.acquire()

~\AppData\Roaming\Python\Python36\site-packages\matplotlib\backends\backend_agg.py in get_renderer(self, cleared) 442 443 if need_new_renderer: --> 444 self.renderer = RendererAgg(w, h, self.figure.dpi) 445 self._lastKey = key 446 elif cleared:

~\AppData\Roaming\Python\Python36\site-packages\matplotlib\backends\backend_agg.py in init(self, width, height, dpi) 90 self.width = width 91 self.height = height ---> 92 self._renderer = _RendererAgg(int(width), int(height), dpi, debug=False) 93 self._filter_renderers = [] 94

ValueError: Image size of 777x120364 pixels is too large. It must be less than 2^16 in each direction.

<matplotlib.figure.Figure at 0x25ea0566710>

결국은 이미지 사이즈가 너무 크다는 거 같은데, 중간의 for문을 주석처리 하면 그래프가 잘 그려집니다. plt.text부분이 문제인 것 같은데, 책에 있는 코드 그대론데 뭐가 문제인지 모르겠습니다.

ploffer11 commented 5 years ago

image for문을 주석처리했을 경우 나오는 그래프입니다.