Hi,

list_plot doesn't plot numpy arrays:

sage: from numpy import *
sage: a = [[x, x**2] for x in arange(-5,5,0.1)]
sage: list_plot(a)

works fine, but

sage: a = array([[x, x**2] for x in arange(-5,5,0.1)])
sage: list_plot(a)

results in

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call
last)

/home/tobias/<ipython console> in <module>()

/opt/sage/local/lib/python2.5/site-packages/sage/plot/plot.py in
list_plot(data, plotjoined, **kwargs)
   4033         P = line(data, **kwargs)
   4034     else:
-> 4035         P = point(data, **kwargs)
   4036     return P
   4037 

/opt/sage/local/lib/python2.5/site-packages/sage/plot/plot.py in
__call__(self, points, coerce, **kwds)
   2732         if coerce:
   2733             xdata = [float(z[0]) for z in points]
-> 2734             ydata = [float(z[1]) for z in points]            
   2735         else:
   2736             xdata = [z[0] for z in points]

TypeError: only length-1 arrays can be converted to Python scalars



OS: Linux darkblue 2.6.24-19-generic #1 SMP Wed Aug 20 22:56:21 UTC 2008
i686 GNU/Linux
Sage Version: SAGE Version 3.1.1, Release Date: 2008-08-17


I have added a patch to address this issue.

Best wishes,

Tobias

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

diff -r 2011c30ecfe0 sage/plot/plot.py
--- a/sage/plot/plot.py	Sun Aug 17 11:39:34 2008 -0700
+++ b/sage/plot/plot.py	Sun Sep 28 21:07:34 2008 +0200
@@ -4027,7 +4027,8 @@ def list_plot(data, plotjoined=False, **
         100.0
 
     """
-    if not isinstance(data[0], (list, tuple)):
+    from numpy import ndarray
+    if not isinstance(data[0], (list, tuple, ndarray)):
         data = zip(range(len(data)),data)
     if plotjoined:
         P = line(data, **kwargs)

Reply via email to