Hi André,
Am Mittwoch, den 01.08.2007, 17:27 +0200 schrieb Andre Wobst:
> Hi all,
>
> On 25.07.07, BK wrote:
> > > is there any way to directly plot scipy/numpy-type arrays? I am reading
> > my data using the scipy.array_import.read_array() method and then doing
> > some data manipulations based on the scipy arrays.
> > Before plotting I currently write the data from the arrays into a list
> > which can be read by the pyx.graph.graphxy.plot() method. Would it be
> > possible to add scipy-type array data to the plot() method of a graph?
>
> Sure ... and its even trivial to implement new data providers for pyx.
> (Let me call instances of the classes defined in pyx.graph.data to be
> "data providers".) Well, there are some non-trivial features in the
> data providers. Think of functions, where the range the function is
> evaluated may depend on the range of the corresponding axes. But those
> things really are advanced features and simple data providers don't
> need to deal with such stuff at all.
>
> The point is that (1) I do not know what people want and need and (2)
> I'm not an scipy user at all. OTOH I do know that pyx.graph.data
> really is very limited in terms of manipulating data. And it's also
> slow. So we just need to find out what's needed for all of you, guys,
> and I'll try to add an appropriate data provider to PyX. I'm sure
> thats better than reimplementing features found in scipy. It's fine
> that PyX comes with some useful data providers, since PyX users really
> should not need to scipy in the first place. But those of you who are
> beeing happy scipy users should get the power out of scipy + PyX most
> easily. Ok, enough blah, blah ...
>
> There is the pyx.graph.data.list class, which takes a list of lists
> and an columns dictionary. For example:
>
> d = pyx.graph.data.list([[1, 2], [3, 4]], x=1, y=2)
>
> (and than proceed with g.plot(d) ...)
>
> This means that you have two points, the first one with x=1 and y=2
> and the second one with x=3 and y=4.
>
> I've just tried to use read_array and provide a useful "adapter" for
> PyX. This looks the following:
>
> from scipy.io import read_array
> from pyx import *
>
> class lists(graph.data._data):
>
> defaultstyles = [graph.style.symbol()]
>
> def __init__(self, title="user provided lists", **columns):
> self.columns = columns
> self.columnnames = columns.keys()
> self.title = title
>
> d = read_array("scipytest.dat")
> g = graph.graphxy(width=10)
> g.plot(lists(x=d[0], y=d[1]))
> g.writeEPSfile("scipytest")
>
Your little adapter does the trick, thanks a lot!
It's indeed very simple and after seeing your solution and looking again
at the 'list' class I feel a little stupid for not figuring it out
myself. I don't know about other scipy users (if there are any others
using PyX, after all scipy comes with its own plotting module
'matplotlib') but for me it's exactly what I needed.
Rather than renaming the old 'list' class you could add the above class
as something like a 'vector' or 'array' class.
Thanks again!
Benedikt
> It's that simple. You really need to understand, that the PyX data
> instances are very thin wrappers and maybe we should even more focus
> on that. While I kind of dislike the above notation (d[0] and d[1] are
> completely independed) and thus I focused on "points" in
> pyx.graph.data.list, why not just add the lists class to PyX as well?
> Maybe the name is not perfect. Well, "list" was not a good idea at
> all ... I could think of renaming the old "list" to "points" and
> adding the "lists" class as shown above. I know that'll break quite
> some code and we could add some deprecated "list = points" to
> pyx.graph.data, but let's keep the focus: Does the signature of the
> lists class shown above match the scipy users needs? Or should it look
> differently?
>
>
> André
>
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
PyX-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyx-user