From: Arnd B. <arn...@we...> - 2012-12-31 15:52:11
|
Hi Joerg, On Mon, 10 Dec 2012, Joerg Lehmann wrote: > Hi Arnd, > > Indeed in PyX 0.12.1, the graph code uses the newly introduced canvas > layer system to specify the drawing order of various parts of the graph. > This fixes an old bug (graph grids had been drawn above the axis ticks). > Unfortunately, this also breaks old scripts - that's why PyX is still, > even after so many years, in an alpha state - and documentation is still > lacking a bit... Well, as it works so nicely for so many bachelor/diploma/PhD theses and papers, one tends to forget this ... ;-). > In any case, in order to draw the bitmap below lines and/or symbols of, > e.g., a function plot use: > > g.layer("filldata").insert(...) I tried to understand the new layers a bit and got to the following point: # <--- snip here from pyx import * c = canvas.canvas() layer1 = c.layer("level1") layer1.text(0, 0, "Hello, layer1") layer2 = c.layer("level2", below="level1") #layer2 = c.layer("level2", below=layer1) # <--- this works layer2.stroke(path.line(0, 0, 2, 0.5), [style.linewidth.THICK, color.rgb.red]) c.writeEPSfile() # <--- and here Gives: Traceback (most recent call last): File "hello_layer1.py", line 6, in <module> layer2 = c.layer("level2", below="level1") File ".../pyx/canvas.py", line 230, in layer self.layers[name] = self.insert(canvas(texrunner=self.texrunner), after=above, before=below) File ".../pyx/canvas.py", line 259, in insert self.items.insert(self.items.index(before), item) ValueError: 'level1' is not in list So it seems that a string is not the right way of specifying a layer: Looking at the code, it cannot work this way, as the `below` string given to `canvas.layer(...)` is passed as `before` argument to `canvas.insert(...)` which is then used to via `self.items.index(before)` to obtain the right index in the list `self.items` containing the different canvas(=layer) instances. So the solution is to provide the layer instance as argument to `below`. Is this the intended way? If yes, I am not sure, whether I read the doc-string to `canvas.layer` correctly, as I interpreted it such that strings would also be correct for `above` and `below` and not just the `name`. Best, Arnd |