Hi list,
is there a nice way to get data row/column names on a
graph.style.rect plot? At the moment I'm using a texrunner to
manually add the names, but it looks as if there might be a way to
combine style.rect with style.bar (see
examples/bargraphs/compare.py, which puts month names on the X
axis).
I've tried the following and many variations, but I always get an error
about a missing value or too many values in the columns.
--------------------------
#!/usr/bin/env python
from pyx import *
data = [
[0, 1, 0, 1, 0.5, "x1", "y1"],
[0, 1, 1, 2, 0.1, "x1", "y2"],
[1, 2, 0, 1, 0.3, "x2", "y1"],
[1, 2, 1, 2, 0.9, "x2", "y2"]
]
xaxis = graph.axis.linear(min=0, painter=graph.axis.painter.bar)
yaxis = graph.axis.linear(min=0, painter=graph.axis.painter.bar)
g = graph.graphxy(width=4, height=4, x=xaxis, y=yaxis, x2=None, y2=None)
g.plot(graph.data.list(data, xmin=1, xmax=2, ymin=3, ymax=4, color=5,
xname=6, yname=7),
[graph.style.rect(),
graph.style.bar()])
g.writeEPSfile("rectangle_test")
------------------------------
The following program demonstrates what I want to do,
but uses a manual texrunner:
--------------------------------
#!/usr/bin/env python
from pyx import *
data = [
[0, 1, 0, 1, 0.5],
[0, 1, 1, 2, 0.1],
[1, 2, 0, 1, 0.3],
[1, 2, 1, 2, 0.9]
]
x_name_list = ["x1", "x2"]
y_name_list = ["y1", "y2"]
xaxis = graph.axis.linear(min=0, painter=None)
yaxis = graph.axis.linear(min=0, painter=None)
g = graph.graphxy(width = 4, height = 4,
x = xaxis, y = yaxis, x2 = None, y2 = None)
g.plot(graph.data.list(data, xmin=1, xmax=2, ymin=3, ymax=4, color=5),
[graph.style.rect()])
plaintex = text.texrunner()
# add the names across the bottom
s = float(g.width) / len(x_name_list)
for i, attr in enumerate(x_name_list):
g.insert(plaintex.text(i * s, -0.5, x_name_list[i]))
# add the names on the side
s = float(g.height) / len(y_name_list)
for i, attr in enumerate(y_name_list):
g.insert(plaintex.text(-0.5, i * s, y_name_list[i]))
g.writeEPSfile("rectangle_test")
----------------------
Thanks,
James
--
James McDermott
PhD candidate in Music Technology
CSG026,
Dept. Computer Science and Information Systems,
University of Limerick,
Ireland.
www.skynet.ie/~jmmcd
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
PyX-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyx-user