[reportlab-users] 4 axes per graph

Dinu Gherman gherman at darwin.in-berlin.de
Wed Aug 24 04:28:14 EDT 2005


Britt Hibbert:

> My question is this: is there a standard way to add labels to all four 
> sides of a graph? Right now, I have my values displayed on the left, 
> my bar labels on the bottom, as is standard. The project requires a 
> graph with values on the right, lettered classifications on the left ( 
> in the same spacing as my values) , bar labels on the bottom, and then 
> a label spanning each four bars ( for a total of 12 bars) on the top. 
> Before I try to reinvent anything here, is there a standard way to 
> accomplish any of this?

To move axes arount see the attributes joinAxis, joinAxisPos and
joinAxisMode on x/y axis in charts/axes.py.

Doing a quick example, on a "standard" cat/value (x/y) barchart
you can use this code to move the category axis to the top (inclu-
ding some tick adjustments):

     bc.categoryAxis.joinAxis = bc.valueAxis
     bc.categoryAxis.joinAxisMode = 'top'
     bc.categoryAxis.tickDown = 0
     bc.categoryAxis.tickUp = 5
     bc.categoryAxis.labels.dy = 10
     bc.categoryAxis.labels.boxAnchor = 's'

or this to move the value axis to the right of the chart:

     bc.valueAxis.joinAxis = bc.categoryAxis
     bc.valueAxis.joinAxisMode = 'right'
     bc.valueAxis.tickLeft = 0
     bc.valueAxis.tickRight = 5
     bc.valueAxis.labels.dx = 10
     bc.valueAxis.labels.boxAnchor = 'w'

The interesting thing to observe is what happens if you try both! ;-)

You should be able to add more axes (to have one on all four sides),
by adding more axes to your drawing and connecting them with the
method joinToAxis(), and providing them with meaningful data.

Your "labels spanning each four bars" is something one would need to
add to the code. If I understand correctly you need that to describe
"bar groups", i.e. a "row" in the data supplied to the chart. This
would be something quite useful for me, too.

Regards,

Dinu



More information about the reportlab-users mailing list