inconsistency in LineCollection

Hello -

I got confused about specifying colors and linewidths for LineCollections.
I think it would be helpful if the docstrings explicitly state that they should be sequences.
I know, they do in some way, but it i

Maybe we should even check this on input, as the error message you get when you don’t do that is confusing.

Let me explain:

from pylab import *
from matplotlib.collections import LineCollection

ax = subplot(111)
ax.add_collection( LineCollection( [[(0,0),(1,1)]], colors=‘r’ ) )
draw()

This works fine, as apparantly colors=‘r’ is interpreted as a sequence.
This does not work, however:

ax.add_collection( LineCollection( [[(0,0),(1,1)]], colors=‘r’, linewidths=2 ) )
draw()

Now I get an error: TypeError: CXX: type error. That’s not too helpful.
What does work is
ax.add_collection
( LineCollection( [[(0,0),(1,1)]], colors=‘r’, linewidths=[2] ) )
draw()

Maybe the confusing part is that just specifying colors=‘r’ works.

Thanks,

Mark

ps. I do all the draws as I am in interactive mode.

This is fixed in svn -- now collection properties should work with a
scalar or iterable so if you find more problems, let us know.

JDH

···

On 10/31/07, Mark Bakker <markbak@...287...> wrote:

This works fine, as apparantly colors='r' is interpreted as a sequence.
This does not work, however:

ax.add_collection( LineCollection( [[(0,0),(1,1)]], colors='r', linewidths=2
) )
draw()

Now I get an error: TypeError: CXX: type error. That's not too helpful.