Adam,

I'm sorry that I wasn't clear before.

Here is a working example:

from pylab import figure, arange
fig = figure(1)
fig.clear()
ax = fig.add_subplot(111)
x = arange(0,1,.25)
y1 = x
y2 = x**2
y3 = x**3
l1 = ax.plot(x,y1,'bo-')
l2 = ax.plot(x,y2,'go-')
l3 = []
for xi,x1 in enumerate(x):
  l3.append(ax.plot(x1,y3[xi],'ro-'))
print l1,l2,l3
leg = ax.legend((l1[0],l2[0],l3[0][0]),('$x$','$x^2$','$x^3$'),
  numpoints=1, loc=0, borderpad=1, shadow=True, fancybox=True)

Note that when l1 and l2 are printed that they are 1-element lists, and l3 is a 
list of 1-element lists, all of which are not the type of handles that legend 
is looking for.  Furthermore, in your code, you are trying to embed these lists 
in yet another layer of list.  

If  your code worked as it was with previous versions of matplotlib, then maybe 
someone with more knowledge could explain what changed to not allow your code 
to work now (it may be related to 
https://github.com/matplotlib/matplotlib/pull/534).

-Sterling

On Oct 27, 2011, at 8:32PM, Adam Mercer wrote:

> On Thu, Oct 27, 2011 at 12:05, Sterling Smith <smit...@fusion.gat.com> wrote:
> 
>> Your example is not complete.  I don't understand the value variable that 
>> you are iterating over, or how it affects the different plots you are making.
> 
> value is simply a list of different datasets to plot, read in using:
> 
> value = []
> for v_file in glob.glob(value_glob):
>  value.append(numpy.atleast_2d(numpy.loadtxt(v_file, converters={0:
> dates.datestr2num})))
> 
> where value_glob specifies a glob pattern of files to read in.
> 
>> I would guess that the problem is that you have a list of tuples of handles 
>> for value_plot, instead of a list of handles.  Note that each of the 
>> plot_date commands returns a length=1 tuple of lines.  So you should pick 
>> out the first item of each tuple, and you probably only need the 1st item of 
>> the value_plot list, since you only give 3 labels.
> 
> I'm not really following you, do you mean something like the following:
> 
> # legend
> date_axes.legend(([morning_plot], [evening_plot], [value_plot[0]]),
>   ("Morning", "Evening", "Value"),
>   numpoints=1, loc=0, borderpad=1, shadow=True, fancybox=True)
> 
> as that results in the same errors?
> 
> Cheers
> 
> Adam


------------------------------------------------------------------------------
The demand for IT networking professionals continues to grow, and the
demand for specialized networking skills is growing even more rapidly.
Take a complimentary Learning@Cisco Self-Assessment and learn 
about Cisco certifications, training, and career opportunities. 
http://p.sf.net/sfu/cisco-dev2dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to