Hi Simson,
On 01.09.05, Simson Garfinkel wrote:
> 1. I'm trying to do a stacked bargraph (I have posted the code that
> does this.) Unfortunately, most of my bars have heights of 0-20
> units, but one has a height of 30,000 units. So I would like to have
> a split in the Y axis between 5,000 and 29,000 units. I can't figure
> out how to do this from the examples.
>
> A friend gave me this code fragment which once worked:
> gr = graph.graphxy(width=15,
> x=graph.axis.bar
> (title="Quanitity of drives where a block occured"),
> y=graph.axis.split
> ([graph.axis.linear(min=0, max=max2+1),
>
> graph.axis.linear(min=max2+10)],
>
> splitlist=[0.8],
>
> title="Gigabytes")
> )
>
>
> But this code doesn't work under 0.8.1; I get the error that
> "splitlist" is an unknown argument.
Right. This is due to the unification of split- and bar axes. A
splitaxis now shares the code of a bar-axis and reads tuples to
identify which of the subaxes the data refers to. This was a big
change, but the previous solution was much more hard-wired.
(When reading data you can use the splitatvalue function in an
math-expression to split at a certain value, which will lead to
behaviour similar to the old one.)
During this unification also the relative sizes between the axes has
been reworked. It now works as for the subaxes in a bar axis by using
a size attribute. Such an attribute needs to be added to an axis, and
for linear axes this has already been done by the sizedlin and the
autosizedlin axes. Hence a working code is:
from pyx import *
g = graph.graphxy(width=8,
x=graph.axis.bar(),
y=graph.axis.split(subaxes=[graph.axis.sizedlin(min=0, max=50, size=5),
graph.axis.sizedlin(min=10000)]))
g.plot(graph.data.list([["a", (0, 10)],
["b", (1, 12345)],
["c", (0, 20)]], xname=1, y=2),
[graph.style.bar()])
g.writeEPSfile("splitbar")
Note that you do not provide ranges to the sizedlin axes when you provide
more than just single data (we can't with axis, which do not span a
range bigger then zero). You could, for example, remove the min=0 and
max=50 for the first sizedaxis. But this would lead the axis to be
partitioned from 10 to 20 only, not containing the 0. As always, this
could be easily fixed by modifying the (in the example above
implicitly inserted) barpos style and setting a fromvalue there, but
this fromvalue needs to be a tuple as well, say (0, 0).
Beside that you'll note, that the styles are not aware of axis brakes
currently. This is an open issue in the current graph design. In case
you want me to start working on that and first of all thinking about
how to solve that in the current design, just do a feature request ...
;-)
> 2. Anything in PyX for doing a 3D bargraph? I can't find anything.
Well, no. I want to make a 3d graph to automatically work not only for
a not yet written surface style, but also for existing styles. The bar
style in 3d is one thing I'm really interested in. I tried to have in
mind that during the design of the graph system all the time. So I
suppose we can add this at some point.
Still you may be asking when we finally get other graph geometries (in
case of 3d, we "just" need to get it back -- there have been some 3d
code in quite old versions, but I first had to work out the graph
design and sticked on a single graph geometry). Meanwhile I do my
3d-plots more or less from scratch. I do not have that many 3d tasks,
a recent example is in http://dx.doi.org/10.1103/PhysRevB.72.045318 (I
hope you can access that -- I can't from here). In case you want to
build something like this at the moment manually, I could send you the
source of one of the 3d figures. (It would not be the first time I
send such 3d code to interested users ... and I do know of some cases,
where other people just did their 3d-stuff allong those lines. Still,
in the end we need a proper 3d-support, which really *is* within the
foreseeable future.)
André
--
by _ _ _ Dr. André Wobst
/ \ \ / ) wobsta@..., http://www.wobsta.de/
/ _ \ \/\/ / PyX - High quality PostScript and PDF figures
(_/ \_)_/\_/ with Python & TeX: visit http://pyx.sourceforge.net/
|