bug in plot

matplotlib apparently can't plot numeric arrays with shape

    > (x,1). Check the code below.

    > This is an important drawback because for some matrix
    > operations, such as concatenation it is necessary to
    > specify if the vector is a line or a column, and these
    > vector can't be plotted.

Try adding the following two lines to matplotlib/lines.py on 144 in
the function set_data

        self._x.shape = len(self._x),
        self._y.shape = len(self._y),

Let me know if that helps.

    > I think this happens for the same reasons matplotlib can't
    > plot matrices as a multiline plot like matlab. IMHO, the
    > plot command should allow for plotting matrices
    > line-by-line like matlab, it is very useful.

Agreed,
JDH

*
        Try adding the following two lines to matplotlib/lines.py on 144 in
the function set_data
self._x.shape = len(self._x),
        self._y.shape = len(self._y),*

No, unfortunately it didn’t help. see what happened:

Python 2.3.3 (#2, Feb 17 2004, 11:45:40)

[GCC 3.3.2 (Mandrake Linux 10.0 3.3.2-6mdk)] on linux2

Type “help”, “copyright”, “credits” or “license” for more information.

from matplotlib.matlab import *

a=arange(9)

a.shape=(9,1)

plot(a)

Traceback (most recent call last):

File “”, line 1, in ?

File “/usr/lib/python2.3/site-packages/matplotlib/matlab.py”, line 1030, in plot

try: lines =  gca().plot(*args, **kwargs)

File “/usr/lib/python2.3/site-packages/matplotlib/axes.py”, line 1324, in plot

self.add_line(line)

File “/usr/lib/python2.3/site-packages/matplotlib/axes.py”, line 381, in add_line

self.update_datalim(corners)

File “/usr/lib/python2.3/site-packages/matplotlib/axes.py”, line 361, in update_datalim

self.dataLim.update(xys, not self.has_data())

TypeError: only rank-0 arrays can be converted to Python scalars.


fiocruz4.jpg
Flávio Codeço Coelho, PhD

Programa de Computação Científica

Fundação Oswaldo Cruz

Rio de Janeiro – Brasil

···