Hi John, could you also subscribe to matplotlib-devel and CC the
messages to me (matplotlib-devel sometimes has a long lag). It would
be nice to have these discussions there for archival purposes and so
that others can offer suggestions. Hopefully, you'll have an easier
time getting sighed up there than you did on matplotlib-users.
> John, First the good news. I've had a good read of
> legend.py and now pretty much understand how it is working.
Excellent, between the 2 of us, that makes at least one person who
understands that code <wink>.
> Now the bad news. The way I'm thinking about these tables
> is that I will want to draw them below the main plot area,
> sort of where the xticklabels go at the moment + the area
> below.
But you should try and code it generally so people can place them
wherever they want right? Perhaps you should construct the table with
a list of horizontal lines and a list of vertical lines and their
respective transforms (see below). Or are you already doing this?
> Now I tried hacking about a table.py copy of legend.py and
> drawing a grid of lines in this area -- the code runs fine
> but I don't get a nice grid of lines (see snippet of code
> below).
> If I cheat and arrange for the drawing to take place within
> the main plot (by carefully fixing the ypos stuff below)
> then things work fine.
> I'm guessing I need to do something to let matplotlib know
> the extent of what I'm drawing, but I am at a loss as to
> what that something is.
> Can you point me in the right direction?
Without a complete code example, I can only guess. My guess is that
you are using the wrong transforms. Each axis instance has a
transAxis and a transData attribute you can use. When you want to
specify a coordinate in axis units (0,1), use the transAxis instance.
If you want to specify a coordinate in data units, use transData.
Eg, if you want the vertical lines (x coords) of your table to line up
with the xticks and the horizontal lines (y coords) of your table to
be in axis units (eg 10% of the axis apart), you would initialize your
line like
ypos = 0.1 # 10% of axes height
line = Line2D( self.dpi, self.bbox,
xdata=(xpos, xpos), ydata=(0, ypos),
color='k', linestyle=':',
transx = self.axes.xaxis.transData,
transy = self.axes.yaxis.transAxis,
)
Make sure you turn clipping off (it appears you did for your
examples), particularly while developing.
> (aside: it did occur to me that one way i could cheat an
> nearly get what i want is to use the bar() method to draw my
> grid + then use the text() method to enter all the text I
> want in the grid...)
Cheating is usually a bad thing. I think you'll need to construct
your own text instances with the same x and y transforms you use for
your lines, eg, x coordinate in data units and y coordinate in axis
units. This will also encapsulate the table as a single instance which
will make it easier to manipulate; eg to set text properties for the
entire table.
Hope this helps, if not send me a complete example with demo script
and I can take a closer look.
JDH