unable to create legend for vlines graph

Hi,

I am unable to create legend for vlines graph. I have modified the vline_demo.py to demonstrate the problem (see below)

···

------------------------------------------------------------
#!/usr/bin/env python
from matplotlib.pyplot import *
from numpy import sin, exp, absolute, pi, arange
from numpy.random import normal

def f(t):
    s1 = sin(2*pi*t)
    e1 = exp(-t)
    return absolute((s1*e1))+.05

t = arange(0.0, 5.0, 0.1)
s = f(t)
nse = normal(0.0, 0.3, t.shape) * s

#plot(t, s+nse, 'b^')
vlines(t, [0], s, label='vline demo')
##Legend creation addedin the demo
legend()
##Legend creation addedin the demo
xlabel('time (s)')
title('Comparison of model with data')
show()
------------------------------------------------------------
I am getting following error stack

## File "\ActivePython25\Lib\site-packages\matplotlib\figure.py", line 772, in draw
## for a in self.axes: a.draw(renderer)
## File "\ActivePython25\Lib\site-packages\matplotlib\axes.py", line 1601, in draw
## a.draw(renderer)
## File "\ACTIVE~1\lib\site-packages\matplotlib\legend.py", line 316, in draw
## self._update_legend_box(renderer)
## File "\ACTIVE~1\lib\site-packages\matplotlib\legend.py", line 626, in _update_legend_box
## legline_marker = legline._legmarker
##AttributeError: 'Line2D' object has no attribute '_legmarker'

Do I have to do something specific to get the legend for vlines graph ?

regards,
Nitin

This is a bug introduced in the recent version of MPL.
While it is fixed in the maintenance branch, there is no release yet.

You may
1) try the svn version
or
2) apply the patch by yourself.
    matplotlib download | SourceForge.net
or
3) use previous release of mpl (0.95 and before)
or
4) draw a line (using plot() command) with same line characteristic
outside the axes area and use this line for the legend.

Regards,

-JJ

···

On Wed, Jan 28, 2009 at 10:05 AM, Nitin Bhide <nitinbhide@...9...> wrote:

Hi,

I am unable to create legend for vlines graph. I have modified the vline_demo.py to demonstrate the problem (see below)
------------------------------------------------------------
#!/usr/bin/env python
from matplotlib.pyplot import *
from numpy import sin, exp, absolute, pi, arange
from numpy.random import normal

def f(t):
   s1 = sin(2*pi*t)
   e1 = exp(-t)
   return absolute((s1*e1))+.05

t = arange(0.0, 5.0, 0.1)
s = f(t)
nse = normal(0.0, 0.3, t.shape) * s

#plot(t, s+nse, 'b^')
vlines(t, [0], s, label='vline demo')
##Legend creation addedin the demo
legend()
##Legend creation addedin the demo
xlabel('time (s)')
title('Comparison of model with data')
show()
------------------------------------------------------------
I am getting following error stack

## File "\ActivePython25\Lib\site-packages\matplotlib\figure.py", line 772, in draw
## for a in self.axes: a.draw(renderer)
## File "\ActivePython25\Lib\site-packages\matplotlib\axes.py", line 1601, in draw
## a.draw(renderer)
## File "\ACTIVE~1\lib\site-packages\matplotlib\legend.py", line 316, in draw
## self._update_legend_box(renderer)
## File "\ACTIVE~1\lib\site-packages\matplotlib\legend.py", line 626, in _update_legend_box
## legline_marker = legline._legmarker
##AttributeError: 'Line2D' object has no attribute '_legmarker'

Do I have to do something specific to get the legend for vlines graph ?

regards,
Nitin

------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options