John, Here is another go at the tables.
Very nice! Soon we'll be able to write matplotlib_excel
> I've created a cell object (see cell.py). This is just a
> rectangle that has some (optional) text associated with it.
A minor comment. Derived artist should implement '_draw', nor 'draw'
as the Artist Base implements the draw method, caches the renderer
instance and then calls _draw. Ie, you want
def _draw(self, renderer, *args, **kwargs):
# draw the rectangle
# use _draw here since this is a base class
Rectangle._draw(self, renderer, *args, **kwargs)
# position the text
self._text.draw(renderer) # use draw here
I noticed I made the same mistake in text.Text. The 'draw' method
there should be renamed _draw.
The motivation here is that you can redraw any artist w/o access to
the renderer since the Artist base has stored it and will use it if
renderer is None
instance.draw() # instance is derived from Artist
> A table is now not much more than just a collection of
All very nice. Two things I think would make a nice addition. You've
provided a great selection of default locations. It shouldn't be too
hard to allow 'loc' to be None, and let the user define a bbox (left,
bottom, width, height) in 0-1 coords to place the table wherever they
def __init__(self, axis, loc=None, bbox=None):
The other thing that might would be a nice addition is a function to
autogenerate tables. Eg, you provide it a list of col header strings,
row header strings, color args and an MxN array of cell text strings,
and it does the dirty work of actually building the table for you. If
col header strings is empty, don't do the row at -1, etc...
Thanks! With your permission, I'll include it in the next matplotlib