Hello everyone,
I'm looking for a way to find the horizontal (x) position of a bar in a
bar graph. I need it because I would like to draw some graphics aligned
underneath each of the bars. The following code does find the position
of the right edge of each of the bars, but it would be more useful to be
able to find where the middle of each bar is. If I knew the width of
each bar I could calculate the position of its middle by doing: x_middle
= x_right  width/2, but I don't really know how to do that either.
Thanks in advance,
Stathis
from pyx import *
d = graph.data.list([
("A", 1404),
("B", 918),
("C", 850)
], y=2, xname=1)
g = graph.graphxy(
width=8,
x=graph.axis.bar(),
y=graph.axis.linear(min=0, max=2000)
)
g.plot(d, [
graph.style.bar([color.rgb.white]),
graph.style.text("y")])
g.dolayout()
x = g.axes["x"].convert(("A", 1));
x = x * g.width + g.xpos;
g.stroke(path.line(x, g.ypos, x, g.ypos + g.height));
x = g.axes["x"].convert(("B", 1));
x = x * g.width + g.xpos;
g.stroke(path.line(x, g.ypos, x, g.ypos + g.height));
x = g.axes["x"].convert(("C", 1));
x = x * g.width + g.xpos;
g.stroke(path.line(x, g.ypos, x, g.ypos + g.height));
g.writePDFfile("graph")
