Adding tables

I was hoping I could do things like specify negative

    > y-positions to draw below the axes, but I now think I'm
    > deluded in thinking this 'cos matplotlib is smart and every
    > time something gets drawn the axes are automagically
    > adjusted to make sure the latest lines/rectangles are
    > included.

If this is the case it appears to me that you are using the
axes.add_line command, no? That is where matplotlib does the
autoscale view limits thingie. There is nothing in the architecture
that prevents you from drawing outside the axes view limits, except
for clipping, which you can set.

I think you should have a Table class which is contained by the axes.
The Table should derive from an Artist and implement the required
_draw method, which is called with a renderer instance. This method
should forward the draw call to all the text, lines and patches
contained by the table, just as legend does.

class Table
    def _draw(self, renderer):
        for line in self._lines: line.draw(renderer)
        for t in self._texts: t.draw(renderer)

This is how Legend does it. If you set it up this way, the axes
instances won't know anything about the line instances and you can
definitely draw outside the axes bbox. If not, matplotlib.axes has
achieved consciousness and we are no longer in control <wink>. Note
that it is critical that you make the call


to allow drawing outside the axes bbox.

Here's an example table class that you can use to draw inside or
outside the axes bbox. Note there is no reason we can't do this at
the figure level, but the advantage of doing it at the axes level is
that you may want some of the lines to be in data coords, eg, the
vertical lines lining up with the xticks in the example you showed me.
It might be worth taking some time to figure out how to have figure
tables or axes tables, eg with a base class and 2 derived classes, but
for now focus on the axes table and we can generalize once you have
the nuances worked out.

class Table(Artist):
    def __init__(self, axes):
        Artist.__init__(self, axes.dpi, axes.bbox)
        self.axes = axes
        left = 0.9
        right = 1.2
        bottom = 0.9
        top = 1.5
        self.line1 = Line2D(
            axes.dpi, axes.bbox,
            (left, left), (bottom, top),

    def _draw(self, renderer):

You can add an add_table method to Axes, and define a list of

    class Axes(Artis):
        def __init__(self, blah, blah):
            # ..snip the other Axes init stuff
            self._tables =

        def add_table(self, table):

        def _draw(self, renderer):
            # ..snip the other draw calls

            for table in self._tables:

I tested my code above with this scheme and it works - it drew a
vertical blue line from inside the axes to outside.

If you have any more troubles send me some code and I'll take a look.