[Matplotlib-users] Plot data from custom class

2007-03-02 Thread Simon Wood
Out of the box matplotlib works great with Numeric and numarray data types. However, I have my own custom class which contains data members, methods and an array of data (underlying C array). Is there a way to expose the C array data to the plot() routines? For example I would like to be able to

Re: [Matplotlib-users] Plot data from custom class

2007-03-02 Thread Glen W. Mabey
On Fri, Mar 02, 2007 at 09:41:03AM -0500, Simon Wood wrote: Out of the box matplotlib works great with Numeric and numarray data types. However, I have my own custom class which contains data members, methods and an array of data (underlying C array). Is there a way to expose the C array data

Re: [Matplotlib-users] Plot data from custom class

2007-03-02 Thread Glen W. Mabey
On Fri, Mar 02, 2007 at 08:44:02AM -0600, Glen W. Mabey wrote: One approach that I've used recently is to simply provide functionality for the [] operator (done by implementing the __getslice__ member function) that accesses the data according to standard slicing rules. Then, you can use

Re: [Matplotlib-users] Plot data from custom class

2007-03-02 Thread John Hunter
On 3/2/07, Simon Wood [EMAIL PROTECTED] wrote: python Out of the box matplotlib works great with Numeric and numarray data types. However, I have my own custom class which contains data members, methods and an array of data (underlying C array). Is there a way to expose the C array data to

Re: [Matplotlib-users] Plot data from custom class

2007-03-02 Thread Christopher Barker
John Hunter wrote: But numpy.asarray, which is what mpl uses to convert inputs to arrays, The whole idea of asarray, is that it should be able to convert properly defined objects without even copying the data. my own custom class which contains data members, methods and an array of data

Re: [Matplotlib-users] Plot data from custom class

2007-03-02 Thread Pierre GM
On Friday 02 March 2007 14:12:24 John Hunter wrote: I still am not able to make my mock-up custom python class work as I would like with asarray (though it works with list). What am I missing? The way I read it this appears to be in support of extension code that wants to expose the array

Re: [Matplotlib-users] Plot data from custom class

2007-03-02 Thread John Hunter
On 3/2/07, Alan Isaac [EMAIL PROTECTED] wrote: John asked: What is the minimum interface for an object to be converted to a numpy sequence via as array? The class must inherit from object. That will probably do it. If all else fails, try fromiter. I know it works with fromiter, but I

Re: [Matplotlib-users] Plot data from custom class

2007-03-02 Thread Simon Wood
On 3/2/07, John Hunter [EMAIL PROTECTED] wrote: John said: ...here is the minimal interface that appears to work class C(object): def __init__(self): self._data = (1,2,3,4,5) def __getitem__(self, i): return self._data[i] def __len__(self): return