From: André Wobst <email@example.com>
To: P V <firstname.lastname@example.org>
Cc: "email@example.com" <firstname.lastname@example.org>
Sent: Monday, September 12, 2011 1:57 PM
[PyX-user] Nested bar graph with integer x-axis
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(<value>). 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.
> 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),
> min = 0,
> max = 0.8,),
> key = legend)
> g.plot([graph.data.file(input_file_name, xname="$1, 0", y = 2, title = "S"),
xname="$1, 1", y = 3, title = "D")],
> 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.
> PyX-user mailing list
by _ _ _ Dr. André Wobst, Amselweg 22, 85716 Unterschleißheim
/ \ \ / ) email@example.com
/ _ \ \/\/ / PyX - High quality PostScript and PDF figures
(_/ \_)_/\_/ with Python & TeX: visit http://pyx.sourceforge.net/