From: André W. <wo...@us...> - 2011-09-12 21:32:46
|
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(<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. 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...@li... > https://lists.sourceforge.net/lists/listinfo/pyx-user -- by _ _ _ Dr. André Wobst, Amselweg 22, 85716 Unterschleißheim / \ \ / ) wo...@us..., http://www.wobsta.de/ / _ \ \/\/ / PyX - High quality PostScript and PDF figures (_/ \_)_/\_/ with Python & TeX: visit http://pyx.sourceforge.net/ |