SourceForge logo
SourceForge logo
Menu

Re: [matplotlib-devel] Another go at tables.

From: John H. <jdh...@ac...> - 2004年02月09日 15:32:56
>>>>> "John" == John Gill <jn...@eu...> writes:
 John> John, Here is another go at the tables.
Very nice! Soon we'll be able to write matplotlib_excel :-)
 John> I've created a cell object (see cell.py). This is just a
 John> 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._set_text_position()
 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
 
 John> A table is now not much more than just a collection of
 John> cells.
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
want it.
Ie, use
class Table
 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
release.
JDH

View entire thread

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /