On 19.09.05, Alan G Isaac wrote:
> Thanks. This helps me understand PyX a bit better.
> I have two embarrasingly simple questions:
> If I want a y-axis title (graph.axis.linear) just above the
> end of the axis, how to
> - left align the title to the leftmost tick position, or
> - center the title over the axis
> I understand the vertical placement, with 'titlepos', but
> the horizontal placement seems hard to override.
The problem is, that the placement of the title takes into account the
labels of the ticks and it's difficult to get rid of that. While one
could argue, that the behaviour is not wanted all the time, the
question is what a useful alternative could look like.
When I designed the graph system my idea was to not spend too many
parameters for the painter. Instead, one could have different painters
for different kind of text placement (and other features). Still, this
is perfectly true, but beside the default painters there aren't much
alternatives distributed with PyX.
Since creating/appding/personalizing of the painters might not be
something you're interested in (although it's not that complicated;
but the mayor problem is that the painters are not exactly build out
of tiny, simple, independend parts), the question is, what's best for
you at the moment and for the whole PyX framework in the future.
For you the most easiest thing is certainly to place the text
manually, especially since you're defining the position where you want
to place the tick quite well.
For the PyX framework the question renders a bit more complicated. If
think of the concept of decorators, the axis painters are such
decorators for a long time already, using some path description
parameters and some other data they somehow recieve. I should also
emphazise, that the painters are a much older construction than
decorators. But still, the question is, whether (some kind of special)
decorators could help to modularize the whole thing. In fact, your
task can already very comfortable be solved at the current CVS version
along the following lines:
from pyx import *
from pyx.graph.axis import lin
from pyx.graph.axis.painter import regular
g = graph.graphxy(width=10,
painter=regular(basepathattrs=[deco.text("text on top", arclenfromend=0, angle=90)])),
The most interesting thing is, that the text decorator is very simple,
contains only a few lines and is absolutely general purpose (doesn't
only work for axes). Moreover, when we would use those decorators
instead of the painters, the whole painter concept with the
complicated argument structure could be removed. However, this would
be a serious change ... in some sence it is comparable with the break
up of the graph styles, which OTOH really was a very good thing.
What do you guys think about this overall. It might be something we
should discuss in detail and think about all the implications ...
> Now to respond to your post:
> When you speak of the "problem coordinates", do you mean the
> default user coordinate system?
No, I meant the coordinates the data is given in, i.e. the values as
stated on the axes.
> Why I'm using graphxy:
> - axes
> - manual ticks
> - titles
> - ability to draw relative to graph using 'pos'
> The last provides great flexibility for changing the
> aspect ratio of the graph while keeping everything
> else the "same", especially when some objects should
> not be transformed. Of course this could be done
> as well using a parameter or two, but I am finding
> graphxy to work rather nicely this way.
> For objects that should be transformed, inserting
> a transformed canvas is useful. Thanks for your help
> (and for this great tool).
It's a very interesting and fruitful discussion to me as well ...
by _ _ _ Dr. André Wobst
/ \ \ / ) wobsta@..., http://www.wobsta.de/
/ _ \ \/\/ / PyX - High quality PostScript and PDF figures
(_/ \_)_/\_/ with Python & TeX: visit http://pyx.sourceforge.net/