From: Paul B. <peb...@gm...> - 2005-09-30 14:55:35
|
John, Since this appears to be a recurrent problem, would it not be better to tes= t for a string and then not do the iteration. In other words, the iteration should be done only for lists and tuples. -- Paul On 9/30/05, John Hunter <jdh...@ac...> wrote: > > >>>>> "Christian" =3D=3D Christian Meesters <mee...@un...> write= s: > > Christian> Hi, I'm looping over a list like this > Christian> ['name',[data_array],'name2',[data_array2],...] like > Christian> this: > > Christian> for x,y in zip(toplot_list,linestyles): if type(x) =3D=3D > Christian> type(array([])): pylab.plot(wavelengths,x,'k%s'% y) > Christian> pylab.legend(toplot_list[toplot_list.index(x)-1]) > > Christian> Now there is a problem with the legend, that I don't > Christian> see all names, but only the last. I seems to me like > Christian> the names get superposed, though I cannot see > Christian> this. Anyway, if I have a name like 'hello' the entry > Christian> in the legend looks like: h e l l o Well, this is not > Christian> quite the behaviour I wanted. Does anybody know how to > Christian> increase the size of the legend automatically so that > Christian> all names can be written out? Or is it possible to > Christian> prevent line break somehow? > > Call the legend outside the list with a list of lines and labels you > want to pass to it. The strange 'hello' artifact you are seeing is > because 'hello' is a string and the legend code is iterating over it. > > Something like > > lines =3D [] > labels =3D [] > for val in something: > lines.extend(plot(val)) > labels.append(somelabel) > legend(lines, labels) > > > Or using autolegend > for val in something: > plot(val, label=3Dsomelabel) > legend() > > > JDH > > > ------------------------------------------------------- > This SF.Net email is sponsored by: > Power Architecture Resource Center: Free content, downloads, discussions, > and more. http://solutions.newsforge.com/ibmarch.tmpl > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > |