[SciPy-user] Failed to plot array using gnuplot-py
oliphant at ee.byu.edu
Wed Feb 1 13:08:39 CST 2006
>On 2/1/06, Robert Kern <robert.kern at gmail.com> wrote:
>>>Not sure what is going on, dont even know if this is a glitch cause by
>>>gnuplot-py or scipy or python itself, but here is what i found out on
>>>Fedora Core 4
>>>It wouldnt plot if i do this:
>>>from scipy import linspace
>>>g = Gnuplot.Gnuplot(debug = 1)
>>>x = linspace(0, 1, 20).astype('f') # i.e. array(0.0, 0.05, 0.10, ... 1.0)
>>>y = linspace(0, 5, 20).astype('f')
>>>d = Gnuplot.Data(x, y)
>>Did you see an error message, or did it just do nothing? What version of Numeric
>>do you have installed? I'm pretty sure the Gnuplot module still uses Numeric and
>>may not recognize numpy arrays. Hopefully, it will try to do something like
>>Numeric.asarray(x). If Numeric's version is >=24.0, that should automatically
>>convert the numpy array to a Numeric array efficiently.
>>robert.kern at gmail.com
>>"In the fields of hell where the grass grows high
>> Are the graves of dreams allowed to die."
>> -- Richard Harter
>>SciPy-user mailing list
>>SciPy-user at scipy.net
>It opened a x11 window, but nothing is plotted. Sometimes it complain
>about the range. I have a feeling it is converting all float to int,
>hence all zero and nothing to plot.
>It plots fine if i make x range >> than 1:
>from scipy import linspace
>g = Gnuplot.Gnuplot(debug = 1)
>x = linspace(0, 10, 20).astype('f') # Make the end point >> 1
>y = linspace(0, 50, 20).astype('f')
>d = Gnuplot.Data(x, y)
>Ahh, my Numeric version is '23.7'
Earlier versions of Numeric didn't handle it well if the return of the
__array__ method (which I suspect it is calling), was not an actual
Numeric ArrayObject. On 32-bit platforms, the ndarray ArrayObject
structure is the same as the Numeric ArrayObject structure. However,
the PyArray_Descr structure is quite a bit different and so I'm sure the
type information is wrong if Numeric is just trying to use the output of
the __array__ method on the ndarray object.
Numeric should have been checking the output of the __array__ method and
raising an error. I know this got changed at some point, but I'm not
sure how early.
More information about the SciPy-user