From: Mark B. <ma...@gm...> - 2007-10-31 12:19:32
|
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. |