problem using LineCollection

Hi,

Sorry, if this has been brought up before, but I missed a while reading
the list.

When I updated my system lately, I also installed the current version of
mpl (0.90.1) and that gave me a DeprecationWarning that I should use
LineCollection now to get my horizontal lines. Well, I didn't figure out
how to do that until now.
(NB I have an own wxpython app which makes heavy use of mpl and mostly
uses subplot instances.)

Well, this code snippet

from pylab import *
from matplotlib.collections import LineCollection

x = subplot(211)
x.add_collection(LineCollection([(0,0)]))

gives the following Traceback:

Exception in Tkinter callback
Traceback (most recent call last):
  File "lib-tk/Tkinter.py", line 1406, in __call__
    return self.func(*args)
  File
"/usr/lib/python2.5/site-packages/matplotlib/backends/backend_tkagg.py",
line 151, in resize
    self.show()
  File
"/usr/lib/python2.5/site-packages/matplotlib/backends/backend_tkagg.py",
line 154, in draw
    FigureCanvasAgg.draw(self)
  File
"/usr/lib/python2.5/site-packages/matplotlib/backends/backend_agg.py",
line 392, in draw
    self.figure.draw(renderer)
  File "/usr/lib/python2.5/site-packages/matplotlib/figure.py", line
601, in draw
    for a in self.axes: a.draw(renderer)
  File "/usr/lib/python2.5/site-packages/matplotlib/axes.py", line 1286,
in draw
    a.draw(renderer)
  File "/usr/lib/python2.5/site-packages/matplotlib/collections.py",
line 700, in draw
    transoffset)
TypeError: CXX : Error creating object of type
N2Py7SeqBaseINS_6ObjectEEE

The traceback is independent of the backend used, same for wxagg at
least.

Guess, I'm missing something stupid. Can somebody enlighten me?

Thanks,
Christian

Hi,

Sorry, if this has been brought up before, but I missed a while reading
the list.

When I updated my system lately, I also installed the current version of
mpl (0.90.1) and that gave me a DeprecationWarning that I should use
LineCollection now to get my horizontal lines. Well, I didn't figure out
how to do that until now.

I think you misread the warning on hlines. You can still use hlines,
just don't pass the "fmt" keyword argument. Instead, use the keyword
arguments of the LineCollection, eg,

                 colors = None,
                 antialiaseds = None,
                 linestyle = 'solid',
                 offsets = None,
                 transOffset = None,#transforms.identity_transform(),
                 norm = None,
                 cmap = None,
                 pickradius = 5,

TypeError: CXX : Error creating object of type
N2Py7SeqBaseINS_6ObjectEEE

This error typically arises when the CXX extension code is expecting a
sequence but getting something different. I can't reproduce it here,
but I am running mpl svn and not 0.90.1. Are you installing from src
or a binary package. In any case, make sure you have a clean install
(remove site-packages/matplotlib and if building from src your "build"
subdirectory before reinstalling).

Can another 0.90.1 user confirm that this is a problem on that version?

JDH

···

On Nov 15, 2007 7:47 AM, Christian Meesters <meesters@...624...> wrote:

Thanks John,

I think you misread the warning on hlines.

Indeed. Problem solved.

This error typically arises when the CXX extension code is expecting a
sequence but getting something different. I can't reproduce it here,
but I am running mpl svn and not 0.90.1. Are you installing from src
or a binary package. In any case, make sure you have a clean install
(remove site-packages/matplotlib and if building from src your "build"
subdirectory before reinstalling).

Can another 0.90.1 user confirm that this is a problem on that version?

I'm using Ubuntu's (7.10) standard package and since I re-installed the
entire system, that was a *clean* install (though not from source). But,
of course, it might just be that my code was inappropriate.

Christian