错误:每当我在绘图中添加图例时,它都会给出以下错误:
我不明白为什么?它在没有ax.legend()
的情况下工作得非常好。
(仅相关帖子:https://github.com/matplotlib/matplotlib/pull/3451)
ValueError Traceback (most recent call last)
/home/abhishek/anaconda2/lib/python2.7/site-packages/IPython/core/formatters.pyc in __call__(self, obj)
305 pass
306 else:
--> 307 return printer(obj)
308 # Finally look for special method names
309 method = get_real_method(obj, self.print_method)
/home/abhishek/anaconda2/lib/python2.7/site-packages/IPython/core/pylabtools.pyc in <lambda>(fig)
225
226 if 'png' in formats:
--> 227 png_formatter.for_type(Figure, lambda fig: print_figure(fig, 'png', **kwargs))
228 if 'retina' in formats or 'png2x' in formats:
229 png_formatter.for_type(Figure, lambda fig: retina_figure(fig, **kwargs))
/home/abhishek/anaconda2/lib/python2.7/site-packages/IPython/core/pylabtools.pyc in print_figure(fig, fmt, bbox_inches, **kwargs)
117
118 bytes_io = BytesIO()
--> 119 fig.canvas.print_figure(bytes_io, **kw)
120 data = bytes_io.getvalue()
121 if fmt == 'svg':
/home/abhishek/anaconda2/lib/python2.7/site-packages/matplotlib/backend_bases.pyc in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, **kwargs)
2242 orientation=orientation,
2243 bbox_inches_restore=_bbox_inches_restore,
-> 2244 **kwargs)
2245 finally:
2246 if bbox_inches and restore_bbox:
/home/abhishek/anaconda2/lib/python2.7/site-packages/matplotlib/backends/backend_agg.pyc in print_png(self, filename_or_obj, *args, **kwargs)
543
544 def print_png(self, filename_or_obj, *args, **kwargs):
--> 545 FigureCanvasAgg.draw(self)
546 renderer = self.get_renderer()
547 original_dpi = renderer.dpi
/home/abhishek/anaconda2/lib/python2.7/site-packages/matplotlib/backends/backend_agg.pyc in draw(self)
457 if __debug__: verbose.report('FigureCanvasAgg.draw', 'debug-annoying')
458
--> 459 self.renderer = self.get_renderer(cleared=True)
460 # acquire a lock on the shared font cache
461 RendererAgg.lock.acquire()
/home/abhishek/anaconda2/lib/python2.7/site-packages/matplotlib/backends/backend_agg.pyc in get_renderer(self, cleared)
474
475 if need_new_renderer:
--> 476 self.renderer = RendererAgg(w, h, self.figure.dpi)
477 self._lastKey = key
478 elif cleared:
/home/abhishek/anaconda2/lib/python2.7/site-packages/matplotlib/backends/backend_agg.pyc in __init__(self, width, height, dpi)
91 self.height = height
92 if __debug__: verbose.report('RendererAgg.__init__ width=%s, height=%s'%(width, height), 'debug-annoying')
---> 93 self._renderer = _RendererAgg(int(width), int(height), dpi, debug=False)
94 self._filter_renderers = []
95
ValueError: Image size of 388x76538 pixels is too large. It must be less than 2^16 in each direction.
<matplotlib.figure.Figure at 0x7fb7fd06c090>
代码:
fig, ax = plt.subplots(figsize=(12,8))
ax.margins(0.05) # Optional, just adds 5% padding to the autoscaling
decision_region(ax)
plot_predict(ax)
ax.set_xlabel('x1')
ax.set_ylabel('x2')
ax.set_title('Hidden units: '+str(hidden_units))
ax.legend()
目前没有回答
相关问题 更多 >
编程相关推荐