Hi Rich,

On 25.03.08, Rich Shepard wrote:
>   I'm reading the users manual and looking at examples on the web site's
> gallery pages (integral seems relevant to me). Attached are two files, one
> has the data and testing application code, the other the plotting functions.
> 
>   Something has been left out. Here's the python traceback:
> 
> Traceback (most recent call last):
>   File "testData.py", line 58, in ?
>     testCode()
>   File "testData.py", line 37, in testCode
>     testFunctions.linearDecrCurve(row[10],row[9])
>   File "/data1/eikos/testFunctions.py", line 186, in linearDecrCurve
>     g.plot(x, y)
>   File "/usr/lib/python2.4/site-packages/pyx/graph/graph.py", line 191, in
> plot
>     plotitems.append(plotitem(self, d, styles))
>   File "/usr/lib/python2.4/site-packages/pyx/graph/graph.py", line 52, in
> __init__
>     self.title = data.title
> AttributeError: 'float' object has no attribute 'title'
> 
>   What have I done incorrectly, and what's the proper way to assign axes
> titles?

The problem is that with PyX you have to wrap your data (either
functions, lists or files) in certain data provider classes, e.g.

   g.plot(graph.data.function("y(x)=sin(x)")
or
   g.plot(graph.data.values(x=[1,2,3], y=[1,4,9]))

As pointed out by David, have a look at the examples on the webpage, 
in particular:

        http://pyx.sourceforge.net/examples/graphs/function.html

Admittedly, an example for the second use case outlined above had been
missing, but has been added in the PyX repository just today due to a
corresponding request on this list.

Note furthermore that when plotting "non-standard" mathematical functions,
especially functions you have defined yourself, you have to tell the
data class under which name you want to access them, e.g.

  def f(x):
      # calculate result y
     return y

  g.plot(graph.data.function("y(x)=f(x)", context={"f": f}))

Finally, as a side remark: Try to start with a reduced version of your
code and build the more complex version only after the simple parts
work. Especially when asking for help on this list, post a minimal
example in order to allow people to quickly identify what's going on.

HTH,

        Jörg

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
PyX-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyx-user

Reply via email to