From: Michael J G. <mic...@fa...> - 2004-09-24 08:29:01
|
Andrea Riciputi venit, vidit, dixit 2004-09-24 10:02: > I'm very sorry, but I'm not able to get the box around my text yet. Here > it is a minimal example. > > h = pyx.graph.graphxy(...) > mytext = h.text(x_pos, y_pos, mystring) > mytext.bbox() > h.writeEPSfile("filename.eps") > > And the resulting plot has not any bounding box around "mystring". > Clearly I'm missing something... Could you explain my fault? The bbox() gives you the PostScript bounding box, that is a "set of 4 numbers" describing a minimal rectangle containing the canvas. It doesn't draw anything. mytext.bbox().path() converts this bbox into a path which you can stroke/draw/fill/whatever. So, what you really want is h.stroke(mytext.bbox().path()) Note that you get the bbox from mytext, but you stroke onto the graph canvas h. You will notice that the bbox is very tight. If you want some padding (space between the rectangular frame and its content) you can enlarge the bbox before converting it into a path, like so: h.stroke(mytext.bbox().enlarged(0.1).path()) This is taken from the "connect" example on the pyx webpage. There you can also see how to fill the frame, for example. Cheers, Michael |