[reportlab-users] variable width stripes in a grid

Dinu Gherman gherman at darwin.in-berlin.de
Mon Feb 6 11:35:55 EST 2006


Yannick Dirou:

> I'm using reportlab to draw charts,
> in fact i use a lineplot and i would like to be able to draw periods 
> in it.
> I thought that i could draw stripes in the background,
> i can use a grid but the stripes are fixed width and cyclic,
> in fact i wish i could set it manually for every stripe.
>
> Is there a way to do it ?

Sure... enjoy the transcendental grid below!

Dinu

     #!/usr/bin/env python

     "Make a 'transcendental' grid."

     from reportlab.graphics.widgets.grids import Grid
     from reportlab.graphics.shapes import Drawing
     from reportlab.graphics.renderSVG import drawToFile
     from math import pi

     g = Grid()
     g.width = 400
     g.height = 200
     g.useLines = 1
     g.useRects = 1
     g.deltaSteps = [10 * int(dig) for dig in str(pi/10)[2:]]

     d = Drawing(g.width, g.height)
     d.add(g)
     drawToFile(d, "grid.svg")



More information about the reportlab-users mailing list