Hi Rahul

On Thu, Feb 14, 2008 at 7:50 PM, Rahul Dabane <[EMAIL PROTECTED]> wrote:
> I'm trying to do something like following...
>  I've two data files:   file1 and file2 with 2 columns each
>  file1           file2
>  d1 t1          x1 y1
>  d2 t2          x2  y2
>  d3 t3          x3  y3
>
>  I want to plot following type information in addition to plotting file1
>  and file2 on same plot
>  f(d1,x1)   f(t1,y1)
>  f(d2,x2)   f(t2,y)
>  f(d3,x3)   f(t3,y3)
>
>  where f is not complicated...
>

There might be a simpler way to do it, but this seems to work:

--------------------- pyx-2file.py ---------------------------
import pyx
# Get dict of columns from first data file
columns = pyx.graph.data.file('f1.dat').columns
# Merge in columns from second data file
columns.update(pyx.graph.data.file('f2.dat').columns)
# Make a PyX data source from the combined dict
dd = pyx.graph.data.values(**columns)
g = pyx.graph.graphxy(width=10,
                      x=pyx.graph.axis.lin(),
                      y=pyx.graph.axis.lin(),
                      )
g.plot([
        # Columns from first file
        pyx.graph.data.data(dd, x='d', y='t'),
        # Columns from second file
        pyx.graph.data.data(dd, x='x', y='y'),
        # Some function of columns from both files
        pyx.graph.data.data(dd, x='d+x', y='t+y'),
        ])
g.writePDFfile("pyx-2file")
--------------------------------------------------------------

------------------------ f1.dat ------------------------------
# d t
  1 10
  2 20
  3 30
--------------------------------------------------------------

------------------------ f2.dat ------------------------------
# x y
  7 17
  8 28
  9 39
--------------------------------------------------------------

HTH

Cheers

Will


-- 

 Dr William Henney, Centro de Radioastronomía y Astrofísica,
 Universidad Nacional Autónoma de México, Campus Morelia

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
PyX-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyx-user

Reply via email to