[Matplotlib-users] contour legend
Hello everybody! I'm trying to make a contour plot and add a legend for it. The code is basically --- from numpy import * from matplotlib.pyplot import * # put anything into x,y,z arrays ctr = contour(x,y,z) # plots ok contours of z(x,y) ctr.collections[0].set_label('z') legend() show() --- The legend() command produces an error (see below). What's wrong with this? Thanks for any help Jakub (Python 2.5 + matplotlib 0.98.3 on Win32) --- ERROR: An unexpected error occurred while tokenizing input The following traceback may be corrupted or invalid The error message is: ('EOF in multi-line statement', (184, 0)) --- AttributeErrorTraceback (most recent call last) C:\Documents and Settings\jurban\ in () C:\Python25\lib\site-packages\matplotlib\pyplot.pyc in legend(*args, **kwargs) 2388 2389 ret = gca().legend(*args, **kwargs) -> 2390 draw_if_interactive() 2391 return ret 2392 if Axes.legend.__doc__ is not None: C:\Python25\lib\site-packages\matplotlib\backends\backend_tkagg.pyc in draw_if_i nteractive() 59 figManager = Gcf.get_active() 60 if figManager is not None: ---> 61 figManager.show() 62 63 C:\Python25\lib\site-packages\matplotlib\backends\backend_tkagg.pyc in show(self ) 389 if sys.platform=='win32' : self.window.update() 390 else: --> 391 self.canvas.draw() 392 self._shown = True 393 C:\Python25\lib\site-packages\matplotlib\backends\backend_tkagg.pyc in draw(self ) 212 213 def draw(self): --> 214 FigureCanvasAgg.draw(self) 215 tkagg.blit(self._tkphoto, self.renderer._renderer, colormode=2) 216 self._master.update_idletasks() C:\Python25\lib\site-packages\matplotlib\backends\backend_agg.pyc in draw(self) 259 260 self.renderer = self.get_renderer() --> 261 self.figure.draw(self.renderer) 262 263 def get_renderer(self): C:\Python25\lib\site-packages\matplotlib\figure.pyc in draw(self, renderer) 757 758 # render the axes --> 759 for a in self.axes: a.draw(renderer) 760 761 # render the figure text C:\Python25\lib\site-packages\matplotlib\axes.pyc in draw(self, renderer, infram e) 1521 1522 for zorder, i, a in dsu: -> 1523 a.draw(renderer) 1524 1525 renderer.close_group('axes') C:\Python25\lib\site-packages\matplotlib\legend.pyc in draw(self, renderer) 195 if not self.get_visible(): return 196 renderer.open_group('legend') --> 197 self._update_positions(renderer) 198 if self._drawFrame: 199 if self.shadow: C:\Python25\lib\site-packages\matplotlib\legend.pyc in _update_positions(self, r enderer) 521 ydata = y*np.ones(handle.get_xdata().shape, float) 522 handle.set_ydata(ydata+h/2.) --> 523 handle._legmarker.set_ydata(ydata+h/2.) 524 elif isinstance(handle, Rectangle): 525 handle.set_y(y+1/4*h) AttributeError: 'Line2D' object has no attribute '_legmarker' - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Fwd: contour legend
Hello everybody! I'm trying to make a contour plot and add a legend for it. The code is basically --- from numpy import * from matplotlib.pyplot import * # put anything into x,y,z arrays ctr = contour(x,y,z) # plots ok contours of z(x,y) ctr.collections[0].set_label('z') legend() show() --- The legend() command produces an error (see below). What's wrong with this? Thanks for any help Jakub (Python 2.5 + matplotlib 0.98.3 on Win32, the same on Fedora 8) --- ERROR: An unexpected error occurred while tokenizing input The following traceback may be corrupted or invalid The error message is: ('EOF in multi-line statement', (184, 0)) --- AttributeErrorTraceback (most recent call last) C:\Documents and Settings\jurban\ in () C:\Python25\lib\site-packages\matplotlib\pyplot.pyc in legend(*args, **kwargs) 2388 2389 ret = gca().legend(*args, **kwargs) -> 2390 draw_if_interactive() 2391 return ret 2392 if Axes.legend.__doc__ is not None: C:\Python25\lib\site-packages\matplotlib\backends\backend_tkagg.pyc in draw_if_i nteractive() 59 figManager = Gcf.get_active() 60 if figManager is not None: ---> 61 figManager.show() 62 63 C:\Python25\lib\site-packages\matplotlib\backends\backend_tkagg.pyc in show(self ) 389 if sys.platform=='win32' : self.window.update() 390 else: --> 391 self.canvas.draw() 392 self._shown = True 393 C:\Python25\lib\site-packages\matplotlib\backends\backend_tkagg.pyc in draw(self ) 212 213 def draw(self): --> 214 FigureCanvasAgg.draw(self) 215 tkagg.blit(self._tkphoto, self.renderer._renderer, colormode=2) 216 self._master.update_idletasks() C:\Python25\lib\site-packages\matplotlib\backends\backend_agg.pyc in draw(self) 259 260 self.renderer = self.get_renderer() --> 261 self.figure.draw(self.renderer) 262 263 def get_renderer(self): C:\Python25\lib\site-packages\matplotlib\figure.pyc in draw(self, renderer) 757 758 # render the axes --> 759 for a in self.axes: a.draw(renderer) 760 761 # render the figure text C:\Python25\lib\site-packages\matplotlib\axes.pyc in draw(self, renderer, infram e) 1521 1522 for zorder, i, a in dsu: -> 1523 a.draw(renderer) 1524 1525 renderer.close_group('axes') C:\Python25\lib\site-packages\matplotlib\legend.pyc in draw(self, renderer) 195 if not self.get_visible(): return 196 renderer.open_group('legend') --> 197 self._update_positions(renderer) 198 if self._drawFrame: 199 if self.shadow: C:\Python25\lib\site-packages\matplotlib\legend.pyc in _update_positions(self, r enderer) 521 ydata = y*np.ones(handle.get_xdata().shape, float) 522 handle.set_ydata(ydata+h/2.) --> 523 handle._legmarker.set_ydata(ydata+h/2.) 524 elif isinstance(handle, Rectangle): 525 handle.set_y(y+1/4*h) AttributeError: 'Line2D' object has no attribute '_legmarker' - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users