Again, the problem with the sample you supply is that you are making 2-D arrays where what you need are 1-D arrays. Simply flattening y and pred before using them makes the script work fine, as attached. Or make them 1-D in the first place.

Eric

Giorgio Luciano wrote:
Thanks to all for the replies :)
I used a tuple to solve the problem because I dind't manage to reshape my array since it comes from a previous slicing, but not it seems to work.
Is it the same problem because this doesn't work ?

from pylab import *
y=array([[ 1.02], [ 1.05], [ 1.03], [ 0.99], [ 0.97], [ 0.95], [ 1. ], [ 0.93], [ 1. ], [ 1. ], [ 0.98], [ 0.98], [ 0.94], [ 0.94], [ 0.96], [ 0.92], [ 1.01], [ 0.96], [ 0.99], [ 0.96], [ 1.03], [ 0.91], [ 0.99], [ 0.98], [ 1. ], [ 0.98], [ 0.96]]) pred=array([[ 1.02875 ], [ 1.03125 ], [ 1.02291667], [ 0.99541667], [ 0.96458333], [ 0.93625 ], [ 0.99375 ], [ 0.93708333], [ 1.00125 ], [ 1.01875 ], [ 0.98541667], [ 0.97291667], [ 0.94708333], [ 0.93458333], [ 0.96625 ], [ 0.92375 ], [ 1.005 ], [ 0.965 ], [ 0.98333333], [ 0.96666667], [ 1.02666667], [ 0.91333333], [ 1.005 ], [ 0.965 ], [ 0.98 ],
       [ 0.98      ], [ 0.98      ]])
figure(2)
r=27
p2=plot(y,pred,'bo')
t1=arange(1,r+1)
for t1 in arange(1,r+1):
   text(y[t1-1], pred[t1-1], str(t1))
show()
######  End Plot 2

and gives this error ??Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Python24\lib\lib-tk\Tkinter.py", line 1345, in __call__
    return self.func(*args)
File "C:\Python24\Lib\site-packages\matplotlib\backends\backend_tkagg.py", line 151, in resize
    self.show()
File "C:\Python24\Lib\site-packages\matplotlib\backends\backend_tkagg.py", line 154, in draw
    FigureCanvasAgg.draw(self)
File "C:\Python24\Lib\site-packages\matplotlib\backends\backend_agg.py", line 392, in draw
    self.figure.draw(renderer)
File "C:\Python24\Lib\site-packages\matplotlib\figure.py", line 545, in draw
    for a in self.axes: a.draw(renderer)
File "C:\Python24\Lib\site-packages\matplotlib\axes.py", line 1067, in draw
    a.draw(renderer)
  File "C:\Python24\Lib\site-packages\matplotlib\text.py", line 340, in draw
    bbox, info = self._get_layout(renderer)
File "C:\Python24\Lib\site-packages\matplotlib\text.py", line 168, in _get_layout
    if self.cached.has_key(key): return self.cached[key]
TypeError: unhashable type

Thanks to all community :)
Giorgio
from pylab import *
y=array([[ 1.02], [ 1.05], [ 1.03], [ 0.99], [ 0.97], [ 0.95], [ 1.  ], 
[ 0.93],  [ 1.  ], [ 1.  ], [ 0.98], [ 0.98], [ 0.94],  [ 0.94],  [ 
0.96],  [ 0.92],  [ 1.01],  [ 0.96], [ 0.99], [ 0.96], [ 1.03],  [ 
0.91],    [ 0.99], [ 0.98], [ 1.  ], [ 0.98], [ 0.96]])
pred=array([[ 1.02875   ], [ 1.03125   ], [ 1.02291667], [ 0.99541667], 
[ 0.96458333], [ 0.93625   ], [ 0.99375   ], [ 0.93708333], [ 1.00125   
],  [ 1.01875   ], [ 0.98541667],  [ 0.97291667],
       [ 0.94708333],  [ 0.93458333],  [ 0.96625   ],   [ 0.92375   ],  
[ 1.005     ], [ 0.965     ], [ 0.98333333], [ 0.96666667], [ 
1.02666667], [ 0.91333333],  [ 1.005     ],  [ 0.965     ], [ 0.98      ],
       [ 0.98      ], [ 0.98      ]])

y = y.flatten()
pred = pred.flatten()
figure()
r=27
p2=plot(y,pred,'bo')
t1=arange(1,r+1)
for t1 in arange(1,r+1):
   text(y[t1-1], pred[t1-1], str(t1))
show()
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to