bug on plot

Matplotlib 0.54.1 still has trouble plotting column or row vectors:

>>> a=arange(10)
>>> plot(a)
[<matplotlib.lines.Line2D instance at 0x40b1ab8c>]
>>> show()
>>> a.shape
(10,)
>>> a.shape=(10,1)
>>> a.shape
(10, 1)
>>> plot(a)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib/python2.3/site-packages/matplotlib/matlab.py", line 1034, in plot
    try: lines =  gca().plot(*args, **kwargs)
  File "/usr/lib/python2.3/site-packages/matplotlib/axes.py", line 1342, in plot
    self.add_line(line)
  File "/usr/lib/python2.3/site-packages/matplotlib/axes.py", line 387, in add_line
    self.update_datalim(corners)
  File "/usr/lib/python2.3/site-packages/matplotlib/axes.py", line 360, in update_datalim
    self.dataLim.update(xys, not self.has_data())
TypeError: only rank-0 arrays can be converted to Python scalars.

How high is this in the todo list?

By the way, does anyone know why Numeric makes this distinction between these shapes ((i,) and (i,j))? I don’t see the need for this. Moreover, arrays without an explicit second dimension, can’t be used on many regular matrix operations, such as concatenate. Even the rank function fails with them:

>>> b=arange(10)
>>> rank(b)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib/python2.3/site-packages/matplotlib/mlab.py", line 870, in rank
    u,s,v  = MLab.svd(x)
  File "/usr/lib/python2.3/site-packages/Numeric/MLab.py", line 367, in svd
    return LinearAlgebra.singular_value_decomposition(v)
  File "/usr/lib/python2.3/site-packages/Numeric/LinearAlgebra.py", line 304, in singular_value_decomposition
    _assertRank2(a)
  File "/usr/lib/python2.3/site-packages/Numeric/LinearAlgebra.py", line 67, in _assertRank2
    raise LinAlgError, 'Array must be two-dimensional'
LinearAlgebraError: Array must be two-dimensional

And it fails saying that the array shoul be two-dimensional!! . Why don’t they make them bi-dimensional to begin with!!!

Sorry about all the complaining (maybe I should have sent this message the Numeric mailing list), but this is really annoying, and creates unnecessary problems for libraries like matplotlib that have to deal with this ambiguity.

Flavio

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

Programa de Computação Científica

Fundação Oswaldo Cruz

Rio de Janeiro – Brasil

···