Hi,

On 07.02.06, Francisco Borges wrote:
> Here is a (minimal) example of how I normally add a title in Pyx. It's a
> sort of a hack but I find it easier than dealing with pyx.text.

Funny idea. But I don't feal

    g.text(g.xpos+0.5*g.width, g.ypos+g.height+0.5,
           "some title",
           [text.halign.center, text.size(2)])

that bad either.

> BTW...  I did appreciate if anyone could tell me of an easy way to keep
> the tick marks at the x2 axis without getting tick labels.

Well, a special painter would do. (One with labelatts=None.) While
this will work, it will create two independend axes. It will just be a
coincidence, that the ticks will be the same (due to using the same
parameters). A better solution would be a linked axis, but then you
will not be able to change axis data, i.e. use a different title. Hmm.

While I'm not yet convinced about the title feature, I would prefere a
solution which has nothing to do with graphs at all. Like the
following:

    #! /usr/bin/env python

    from pyx import *
    from pyx.graph import graphxy, data, axis

    class titlecanvas(canvas.canvas):

        def mywrite(self, filename, title):
            bbox = self.bbox()
            self.insert(self.text(0.5*(bbox.left()+bbox.right()), 
bbox.top()+0.5, title,
                                  [text.halign.center, text.size(2)]))
            self.writeEPSfile(filename)

    WIDTH = 10
    XMIN, XMAX =0, 10

    xax = axis.linear(min=XMIN, max=XMAX, title=r'$\sin(2x)\sin(x)x$')
    yax = axis.linear(title='$y$')

    c = titlecanvas()
    g = c.insert(graphxy(width=WIDTH, x=xax, y=yax))

    g.plot(graph.data.function("y(x) = sin(2*x)*sin(x)*x", points=300))

    c.mywrite(__file__[:-3], "some title")

Sure, since we need our own canvas here, we need to wrap the graph
into that canvas. And the title is centered over the whole output, not
just the graph itself (well, you could remove the bbox.left(), since
graph.xpos == 0, but that's not a serious suggestion).

It would all become better, when the title would become a canvas
feature (or better a page). Than you would be able to use it in all
writeXXXfile methods. In case this is a strong feature request
supported by quite some people, we could add that to the PyX core.
Still, the other day somebody want's a bottom line etc. In the end I
would much more like to see a box system, where you could take your
content and add some other material around that. And I do not want to
make to many things, which will not fit well into such a framework.


André

-- 
by  _ _      _    Dr. André Wobst
   / \ \    / )   [EMAIL PROTECTED], http://www.wobsta.de/
  / _ \ \/\/ /    PyX - High quality PostScript and PDF figures
 (_/ \_)_/\_/     with Python & TeX: visit http://pyx.sourceforge.net/


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
PyX-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyx-user

Reply via email to