Hi,

let me answer your first question here only.

On 08.05.06, trevorw wrote:
> 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 ...


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/
from pyx import *

d = graph.data.file("months.dat", lineno=0)

subaxes = [graph.axis.lin(title=month[0], parter=None, linkpainter=None,
                          
painter=graph.axis.painter.regular(basepathattrs=None))
           for month in d.columns["month"]]

g = graph.graphxy(width=8, x=graph.axis.bar(subaxes=subaxes, 
painter=graph.axis.painter.bar(nameattrs=None)))
g.plot(graph.data.data(d, xname="lineno-1", y="min", ystack="max"),
       [graph.style.bar(),
        graph.style.stackedbarpos("ystack"),
        graph.style.bar([color.rgb.green])])
g.writeEPSfile("months")
from pyx import *

d = graph.data.file("months.dat")

subaxes = dict([(month, graph.axis.lin(title=month[0], parter=None, 
linkpainter=None,
                                       
painter=graph.axis.painter.regular(basepathattrs=None)))
                for month in d.columns["month"]])

g = graph.graphxy(width=8, x=graph.axis.bar(subaxes=subaxes, 
painter=graph.axis.painter.bar(nameattrs=None)))
g.plot(graph.data.data(d, xname="month", y="min", ystack="max"),
       [graph.style.bar(),
        graph.style.stackedbarpos("ystack"),
        graph.style.bar([color.rgb.green])])
g.writeEPSfile("months")
#month    min max
January    -5   1
Feburary   -4   3
March       0   8
April       3  13
May         7  18
June       10  21
July       12  23
August     12  23
September   8  19
October     4  13
November    0   6
December   -4   2

Reply via email to