Hi Gert, it's not a bug. (Well, it depends. You can call it a bug, sure. But at least it does work as designed. Probably the design is broken. However, there is quite some history behind the formula evaluation in the data providers, remember my old (and odd) mathtree code.)
The points data provider does not allow for formulas. However, you can nest the
data providers to properly add the formula evaluation:
from pyx import *
data = [[1, 2, 3], [4, 5, 6]]
g = graph.graphxy(width=8, x=graph.axis.nestedbar())
g.plot([graph.data.data(graph.data.points(data, xname=1, y=2), xname="xname,
0"),
graph.data.data(graph.data.points(data, xname=1, y=3), xname="xname,
1")],
[graph.style.bar()])
g.writePDFfile("nestedbar")
However, it would probably be fine too, to already pass the proper data type
(i.e. a tuple, or, to be more precise, something that behaves well when using
value[0] and value[1:]).
André
Am 13.09.2011 um 07:58 schrieb Gert-Ludwig Ingold:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Dear André,
>
>> formula. Just write xname="int($1), 0" – it's that simple. As a third
>> solution you could read the data yourself and use a different data
>> provider like graph.data.points passing integer values for the bar axis
>> data.
>
> since you mention graph.data.points in connection with nested bars, I would
> like to ask about the following code
>
> from pyx import *
>
> data = [[1, 2, 3], [4, 5, 6]]
>
> g = graph.graphxy(width=8, x=graph.axis.nestedbar())
> g.plot([graph.data.points(data, xname="$1, 0", y=2),
> graph.data.points(data, xname="$1, 1", y=3)],
> [graph.style.bar()])
> g.writePDFfile("nestedbar")
>
> which results in a TypeError with Pyx-0.11.1:
>
> if abs(v) > l or (not addlinenumbers and abs(v) == l):
> TypeError: bad operand type for abs(): 'str'
>
> arising from line 135 in graph/data.py. It seems that data.py tries
> to take the absolute value of the string "$1, 0". Am I doing something
> wrong or is this a bug?
>
> Best regards,
> Gert
>
> - --
> Gert-Ludwig Ingold email: [email protected]
> Institut für Physik Phone: +49-821-598-3234
> Universität Augsburg Fax : +49-821-598-3222
> D-86135 Augsburg WWW : www.physik.uni-augsburg.de/theo1/ingold
> Germany PGP : 86FF5A93, key available from homepage
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAk5u8RYACgkQ4E2iM4b/WpMRQQCfQuvH1/8oCJQ7s4AzXQHwwslF
> SuoAnir0+fDvTiTSnRkrGemfySNzET8J
> =3Fc1
> -----END PGP SIGNATURE-----
>
> ------------------------------------------------------------------------------
> BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, CA
> Learn about the latest advances in developing for the
> BlackBerry® mobile platform with sessions, labs & more.
> See new tools and technologies. Register for BlackBerry® DevCon today!
> http://p.sf.net/sfu/rim-devcon-copy1
> _______________________________________________
> PyX-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/pyx-user
--
by _ _ _ Dr. André Wobst, Amselweg 22, 85716 Unterschleißheim
/ \ \ / ) [email protected], http://www.wobsta.de/
/ _ \ \/\/ / PyX - High quality PostScript and PDF figures
(_/ \_)_/\_/ with Python & TeX: visit http://pyx.sourceforge.net/
smime.p7s
Description: S/MIME cryptographic signature
------------------------------------------------------------------------------ BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, CA Learn about the latest advances in developing for the BlackBerry® mobile platform with sessions, labs & more. See new tools and technologies. Register for BlackBerry® DevCon today! http://p.sf.net/sfu/rim-devcon-copy1
_______________________________________________ PyX-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/pyx-user
