Re: [PyX-user] Nested bar graph with integer x-axis

 Re: [PyX-user] Nested bar graph with integer x-axis From: P V - 2011-09-12 21:03:32 Attachments: Message as HTML ```Tried xname = 'int(\$1), 0' and it worked. Thanks Andre! ________________________________ From: André Wobst To: P V Cc: "pyx-user@..." Sent: Monday, September 12, 2011 1:57 PM Subject: Re: [PyX-user] Nested bar graph with integer x-axis Hi, Am 12.09.2011 um 00:45 schrieb P V: > I'm trying to create a nested bar graph and everything works fine, except for one thing: the x-axis ticks appear as floats, even though in the input file they are integers. The default label output for a bar axis uses the string representation of the values, i.e. str(). As the file input reader converts all data to floats (and keeps the strings for all other values), you get the ".0" due to the floating point input. There are several solutions to fix this behavior. You can alter your data files and place your integer data in double quotes. Then the data is keeps as string input which is fine for bar axes. (Again, note that a bar axis works on discrete data, which can be a float or a string or about almost any other type.) Alternatively you can convert the floats back to integers in the 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. Best, André > Since in my setting it does not make sense for me to present floats/real numbers, can you suggest a way for making the x-axis have integer values? > > Here is the critical sample of my code: > >  g = graph.graphxy(width = 6, >                    x = graph.axis.nestedbar(title = 'FSA), >                    y = graph.axis.linear(title = 'P', >                                          painter = graph.axis.painter.regular(gridattrs = [style.dash((30, 30, 30), 10), >                                                                                            style.linewidth.THIN],), >                                          min = 0, >                                          max = 0.8,), >                    key = legend) > >  g.plot([graph.data.file(input_file_name, xname="\$1, 0", y = 2, title = "S"), >          graph.data.file(input_file_name, xname="\$1, 1", y = 3, title = "D")], >          [graph.style.bar()]) > > ------------------------------------------------------------------------------ > Using storage to extend the benefits of virtualization and iSCSI > Virtualization increases hardware utilization and delivers a new level of > agility. Learn what those decisions are and how to modernize your storage > and backup environments for virtualization. > http://www.accelacomm.com/jaw/sfnl/114/51434361/_______________________________________________ > PyX-user mailing list > PyX-user@... > https://lists.sourceforge.net/lists/listinfo/pyx-user -- by  _ _      _    Dr. André Wobst, Amselweg 22, 85716 Unterschleißheim   / \ \    / )  wobsta@..., http://www.wobsta.de/   / _ \ \/\/ /    PyX - High quality PostScript and PDF figures (_/ \_)_/\_/    with Python & TeX: visit http://pyx.sourceforge.net/```

 [PyX-user] Nested bar graph with integer x-axis From: P V - 2011-09-11 22:45:13 Attachments: Message as HTML ```Hi all, I'm trying to create a nested bar graph and everything works fine, except for one thing: the x-axis ticks appear as floats, even though in the input file they are integers. Since in my setting it does not make sense for me to present floats/real numbers, can you suggest a way for making the x-axis have integer values? Here is the critical sample of my code:  g = graph.graphxy(width = 6,                     x = graph.axis.nestedbar(title = 'FSA),                     y = graph.axis.linear(title = 'P',                                           painter = graph.axis.painter.regular(gridattrs = [style.dash((30, 30, 30), 10),                                                                                             style.linewidth.THIN],),                                           min = 0,                                           max = 0.8,),                     key = legend)   g.plot([graph.data.file(input_file_name, xname="\$1, 0", y = 2, title = "S"),           graph.data.file(input_file_name, xname="\$1, 1", y = 3, title = "D")],          [graph.style.bar()]) ```
 Re: [PyX-user] Nested bar graph with integer x-axis From: Axel Freyn - 2011-09-12 09:47:18 ```Hi, On Sun, Sep 11, 2011 at 03:45:07PM -0700, P V wrote: > Hi all, > > I'm trying to create a nested bar graph and everything works fine, > except for one thing: the x-axis ticks appear as floats, even though > in the input file they are integers. > > Since in my setting it does not make sense for me to present > floats/real numbers, can you suggest a way for making the x-axis have > integer values? > > Here is the critical sample of my code: > >  g = graph.graphxy(width = 6, >                     x = graph.axis.nestedbar(title = 'FSA), >                     y = graph.axis.linear(title = 'P', >                                           painter = graph.axis.painter.regular(gridattrs = [style.dash((30, 30, 30), 10), >                                                                                             style.linewidth.THIN],), >                                           min = 0, >                                           max = 0.8,), >                     key = legend) > >   g.plot([graph.data.file(input_file_name, xname="\$1, 0", y = 2, title = "S"), >           graph.data.file(input_file_name, xname="\$1, 1", y = 3, title = "D")], >          [graph.style.bar()]) You could try to pass a parter to your x-axis, e.g. x = graph.axis.nestedbar(title = 'FSA', parter = graph.axis.parter.linear([2,1]) ) should generated ticks at integer positions (see http://pyx.sourceforge.net/manual/axis.html#graph.axis.parter.linear ) Axel ```
 Re: [PyX-user] Nested bar graph with integer x-axis From: P V - 2011-09-12 17:55:47 Attachments: Message as HTML ```Thanks for the reply Axel. Unfortunately, class axis.nestedbar does not take a ``parter'' argument... Also, just in case my problem was not clear: the x-axis has labels 1.0, 2.0, 3.0, ... . I'd like them to be 1, 2, 3, ... . ________________________________ From: Axel Freyn To: P V Cc: "pyx-user@..." Sent: Monday, September 12, 2011 2:46 AM Subject: Re: [PyX-user] Nested bar graph with integer x-axis Hi, On Sun, Sep 11, 2011 at 03:45:07PM -0700, P V wrote: > Hi all, > > I'm trying to create a nested bar graph and everything works fine, > except for one thing: the x-axis ticks appear as floats, even though > in the input file they are integers. > > Since in my setting it does not make sense for me to present > floats/real numbers, can you suggest a way for making the x-axis have > integer values? > > Here is the critical sample of my code: > >  g = graph.graphxy(width = 6, >                     x = graph.axis.nestedbar(title = 'FSA), >                     y = graph.axis.linear(title = 'P', >                                           painter = graph.axis.painter.regular(gridattrs = [style.dash((30, 30, 30), 10), >                                                                                             style.linewidth.THIN],), >                                           min = 0, >                                           max = 0.8,), >                     key = legend) > >   g.plot([graph.data.file(input_file_name, xname="\$1, 0", y = 2, title = "S"), >           graph.data.file(input_file_name, xname="\$1, 1", y = 3, title = "D")], >          [graph.style.bar()]) You could try to pass a parter to your x-axis, e.g. x = graph.axis.nestedbar(title = 'FSA', parter = graph.axis.parter.linear([2,1]) ) should generated ticks at integer positions (see http://pyx.sourceforge.net/manual/axis.html#graph.axis.parter.linear ) Axel```
 Re: [PyX-user] Nested bar graph with integer x-axis From: André Wobst - 2011-09-12 21:32:46 Attachments: smime.p7s ```Hi, Am 12.09.2011 um 00:45 schrieb P V: > I'm trying to create a nested bar graph and everything works fine, except for one thing: the x-axis ticks appear as floats, even though in the input file they are integers. The default label output for a bar axis uses the string representation of the values, i.e. str(). As the file input reader converts all data to floats (and keeps the strings for all other values), you get the ".0" due to the floating point input. There are several solutions to fix this behavior. You can alter your data files and place your integer data in double quotes. Then the data is keeps as string input which is fine for bar axes. (Again, note that a bar axis works on discrete data, which can be a float or a string or about almost any other type.) Alternatively you can convert the floats back to integers in the 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. Best, André > Since in my setting it does not make sense for me to present floats/real numbers, can you suggest a way for making the x-axis have integer values? > > Here is the critical sample of my code: > > g = graph.graphxy(width = 6, > x = graph.axis.nestedbar(title = 'FSA), > y = graph.axis.linear(title = 'P', > painter = graph.axis.painter.regular(gridattrs = [style.dash((30, 30, 30), 10), > style.linewidth.THIN],), > min = 0, > max = 0.8,), > key = legend) > > g.plot([graph.data.file(input_file_name, xname="\$1, 0", y = 2, title = "S"), > graph.data.file(input_file_name, xname="\$1, 1", y = 3, title = "D")], > [graph.style.bar()]) > > ------------------------------------------------------------------------------ > Using storage to extend the benefits of virtualization and iSCSI > Virtualization increases hardware utilization and delivers a new level of > agility. Learn what those decisions are and how to modernize your storage > and backup environments for virtualization. > http://www.accelacomm.com/jaw/sfnl/114/51434361/_______________________________________________ > PyX-user mailing list > PyX-user@... > https://lists.sourceforge.net/lists/listinfo/pyx-user -- by _ _ _ Dr. André Wobst, Amselweg 22, 85716 Unterschleißheim / \ \ / ) wobsta@..., http://www.wobsta.de/ / _ \ \/\/ / PyX - High quality PostScript and PDF figures (_/ \_)_/\_/ with Python & TeX: visit http://pyx.sourceforge.net/ ```
 Re: [PyX-user] Nested bar graph with integer x-axis From: P V - 2011-09-12 21:03:32 Attachments: Message as HTML ```Tried xname = 'int(\$1), 0' and it worked. Thanks Andre! ________________________________ From: André Wobst To: P V Cc: "pyx-user@..." Sent: Monday, September 12, 2011 1:57 PM Subject: Re: [PyX-user] Nested bar graph with integer x-axis Hi, Am 12.09.2011 um 00:45 schrieb P V: > I'm trying to create a nested bar graph and everything works fine, except for one thing: the x-axis ticks appear as floats, even though in the input file they are integers. The default label output for a bar axis uses the string representation of the values, i.e. str(). As the file input reader converts all data to floats (and keeps the strings for all other values), you get the ".0" due to the floating point input. There are several solutions to fix this behavior. You can alter your data files and place your integer data in double quotes. Then the data is keeps as string input which is fine for bar axes. (Again, note that a bar axis works on discrete data, which can be a float or a string or about almost any other type.) Alternatively you can convert the floats back to integers in the 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. Best, André > Since in my setting it does not make sense for me to present floats/real numbers, can you suggest a way for making the x-axis have integer values? > > Here is the critical sample of my code: > >  g = graph.graphxy(width = 6, >                    x = graph.axis.nestedbar(title = 'FSA), >                    y = graph.axis.linear(title = 'P', >                                          painter = graph.axis.painter.regular(gridattrs = [style.dash((30, 30, 30), 10), >                                                                                            style.linewidth.THIN],), >                                          min = 0, >                                          max = 0.8,), >                    key = legend) > >  g.plot([graph.data.file(input_file_name, xname="\$1, 0", y = 2, title = "S"), >          graph.data.file(input_file_name, xname="\$1, 1", y = 3, title = "D")], >          [graph.style.bar()]) > > ------------------------------------------------------------------------------ > Using storage to extend the benefits of virtualization and iSCSI > Virtualization increases hardware utilization and delivers a new level of > agility. Learn what those decisions are and how to modernize your storage > and backup environments for virtualization. > http://www.accelacomm.com/jaw/sfnl/114/51434361/_______________________________________________ > PyX-user mailing list > PyX-user@... > https://lists.sourceforge.net/lists/listinfo/pyx-user -- by  _ _      _    Dr. André Wobst, Amselweg 22, 85716 Unterschleißheim   / \ \    / )  wobsta@..., http://www.wobsta.de/   / _ \ \/\/ /    PyX - High quality PostScript and PDF figures (_/ \_)_/\_/    with Python & TeX: visit http://pyx.sourceforge.net/```
 Re: [PyX-user] Nested bar graph with integer x-axis From: Gert-Ludwig Ingold - 2011-09-13 06:21:09 ```-----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: Gert.Ingold@... Institut für Physik Phone: +49-821-598-3234 Universität Augsburg Fax : +49-821-598-3222 D-86135 Augsburg WWW : http://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----- ```
 Re: [PyX-user] Nested bar graph with integer x-axis From: André Wobst - 2011-09-13 07:05:39 Attachments: smime.p7s ```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: Gert.Ingold@... > Institut für Physik Phone: +49-821-598-3234 > Universität Augsburg Fax : +49-821-598-3222 > D-86135 Augsburg WWW : http://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 > PyX-user@... > https://lists.sourceforge.net/lists/listinfo/pyx-user -- by _ _ _ Dr. André Wobst, Amselweg 22, 85716 Unterschleißheim / \ \ / ) wobsta@..., http://www.wobsta.de/ / _ \ \/\/ / PyX - High quality PostScript and PDF figures (_/ \_)_/\_/ with Python & TeX: visit http://pyx.sourceforge.net/ ```
 Re: [PyX-user] Nested bar graph with integer x-axis From: Gert-Ludwig Ingold - 2011-09-13 07:14:21 ```-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Dear André, > The points data provider does not allow for formulas. However, you can > nest the data providers to properly add the formula evaluation: thanks, that works nicely. Would it make sense to add a remark to the description of bargraphs/compare.py? Otherwise, I might consider including this idea into the FAQ. Best regards, Gert - -- Gert-Ludwig Ingold email: Gert.Ingold@... Institut für Physik Phone: +49-821-598-3234 Universität Augsburg Fax : +49-821-598-3222 D-86135 Augsburg WWW : http://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/ iEYEARECAAYFAk5vAsEACgkQ4E2iM4b/WpNNiQCgi6Y8vp0bnN91O5Loz+Rw452o 5J0An2r6v0kKRSrput2uYlwRHnzYTAC6 =V+Tu -----END PGP SIGNATURE----- ```
 Re: [PyX-user] Nested bar graph with integer x-axis From: Joerg Lehmann - 2011-09-13 08:02:59 ```Dear Gert! On 13.09.11, Gert-Ludwig Ingold wrote: > > The points data provider does not allow for formulas. However, you can > > nest the data providers to properly add the formula evaluation: > > thanks, that works nicely. Would it make sense to add a remark to the > description of bargraphs/compare.py? Otherwise, I might consider including > this idea into the FAQ. Just my two cents on this: I knew that one cannot use formulae in data.points, but I was not aware that one can nest data providers! ;-) So maybe adding a remark in the FAQ might be a good idea... Cheers, Jörg ```