On 5/11/06, Andre Wobst <[EMAIL PROTECTED]> wrote:
let me answer your first question here only.

> One of the charts I need to create is a stacked bar graph for the 12
> months of the year. I want to label my x-axis with the first letter of
> the month for each month. However when I do this, the duplicate letters
> get removed. How do I get around this?

There is a simple and serious answer: You can't. All you can do is to
change the way the data is shown, but not the way the data is
processed (for the later you *need* different values for each bar).

Basically there are at least three options comming to mind.

1) Currently the names using for identifying the bars are also used as
the bar names by the bar painter. We could have an additional
translation step in between there. (BTW we had that ... called xnames
IIRC in earlier versions, where the bars internally have always been
integers. Now they can be of any type and thus the additional
translation was removed.) At the moment we don't have such an
translation step and thus this option is not available.

2) We could modify the painter to different names. This is similar to
the previous idea, but it would just affect the painter. Better and
easier to implement ontop what we have. But still: not available.

3) You could not use the bar painter to write the titles for the bars,
but the subaxes. Just set a proper title and painter there and you're
done. So now: How to access the subaxes. Well, you can pass a
predefined list (or dictionary in the upcomming PyX 0.9) to the
subaxes attribute of the bar axis. Enclosed you find two solutions.
The dictionary solution, which I like better, works on PyX 0.9 only.

Note that the option 3 has limitations: Since all subaxes paint their
title independently from each other, the baseline might differ.
However, for uppercase letters on usual fonts this is should not harm.
(In case you don't really understand what I mean, change month[0] to
month[0].lower() ... then it becomes totally ugly ... of course one
could work around that by some TeX ticks like vphantom, which is BTW
similar to the equalalign features of the axis painters, but there the
alignment is adjusted at the painters, i.e. within PyX.)

Overall you see, that this is far from optimal. I think we should add
a names-feature to the bar painter, i.e. implement option 2. It would
solve the problem without any drawbacks and it would be some internal
feature of the painter only (much better than option 1).

So far I hope this is of any help for you. I'm not sure whether
you're really interested in the underlying problem. On the other hand
you may just want to take the code and use this. Fine as well ...

I have just tried your months.py, but getting errors:

$ python months.py
Traceback (most recent call last):
 File "months.py", line 9, in ?
   g = graph.graphxy(width=8, x=graph.axis.bar(subaxes=subaxes,
painter=graph.axis.painter.bar(nameattrs=None)))
 File "/usr/lib/python2.4/site-packages/pyx/graph/graph.py", line
435, in __init__
   self.initaxes(axes)
 File "/usr/lib/python2.4/site-packages/pyx/graph/graph.py", line
362, in initaxes
   self.axes[key] = axis.anchoredaxis(aaxis, key)
 File "/usr/lib/python2.4/site-packages/pyx/graph/axis/axis.py", line
467, in __init__
   self.data = axis.createdata(errorname)
 File "/usr/lib/python2.4/site-packages/pyx/graph/axis/axis.py", line
310, in createdata
   self.addsubaxis(data, name, subaxis, errorname)
 File "/usr/lib/python2.4/site-packages/pyx/graph/axis/axis.py", line
314, in addsubaxis
   subaxis = anchoredaxis(subaxis, "%s, subaxis %s" % (errorname, name))
 File "/usr/lib/python2.4/site-packages/pyx/graph/axis/axis.py", line
467, in __init__
   self.data = axis.createdata(errorname)
AttributeError: 'str' object has no attribute 'createdata'
$

Paul


-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0709&bid&3057&dat1642
_______________________________________________
PyX-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyx-user

Reply via email to