SourceForge logo
SourceForge logo
Menu

matplotlib-devel

From: John G. <jn...@eu...> - 2004年02月09日 10:13:10
John,
Here is another go at the tables.
I've created a cell object (see cell.py). This is just a rectangle that
has some (optional) text associated with it.
A table is now not much more than just a collection of cells.
You just create the table and then add all the cells. For each cell
you specify the row and column. Negative column numbers are allowed,
which is handy for things like row labels.
See table_demo3.py for an example of how it works. The demo also
includes some stuff to help with coming up with nice (?) pastel shades
to use as colours.
I've also got an option that allows you to specify that a particular
column should have its width worked out automagically based on the text
in the cells in the column (again see the demo).
axes.py is almost the same as the last version i sent you, the only
change is this little bug fix:
304c305
< (iterable(color) and len(color)==3 and len(x)!=3) or
---
> (iterable(color) and len(color)==3 and len(left)!=3) or
John
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
From: John G. <jn...@eu...> - 2004年02月10日 11:33:41
See attached.
table.py now has dataTable which does the autogenerating of tables given
cells, rows and column stuff and tries to do sensible things if only a
subset is actually supplied.
data_table_demo.py is an example of dataTable in action.
I've included the latest version of cell.py 'cos I think I've added more
to that in the last 24 hours as well.
re: including this in the next release, that would be excellent.
john 
> 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
> 
> 
From: John H. <jdh...@ac...> - 2004年02月10日 15:16:16
>>>>> "John" == John Gill <jn...@eu...> writes:
 John> See attached. table.py now has dataTable which does the
 John> autogenerating of tables given cells, rows and column stuff
 John> and tries to do sensible things if only a subset is actually
 John> supplied.
 John> data_table_demo.py is an example of dataTable in action.
 John> I've included the latest version of cell.py 'cos I think
 John> I've added more to that in the last 24 hours as well.
I made a two minor changes
 * dataTable is renamed to data_table to be consistent with matplotlib
 function naming.
 * I moved Cell into table.py and removed cell.py
If I could impose on you one more time. I would like to add a table
screenshot to the web page. Something along the lines of the first
table example you sent (with the stacked bar chart) but using
data_table to build the table. The code should be as simple as
possible since we want to emphasize the ease of use. Do you have some
data you can use to make a table that can be displayed on the web? I
have a data dir in the examples dir that I use to distribute data.
 John> re: including this in the next release, that would be
 John> excellent.
Great -- it's in CVS. I took the liberty of adding 
 Author : John Gill <jn...@eu...>
 Copyright : 2004 John Gill and John Hunter
 License : matplotlib license
Thanks a lot - this is a great addition.
JDH
From: John G. <jn...@eu...> - 2004年02月12日 15:15:20
John,
Thanks for all the fixes. Having data_table as matplotlib.matlab.table
is good + also on the axes.
I've attached my latest demo script -- was in the process of trying to
simplify the example for you, but have been a bit busy the last couple
of days.
I split the colour generating stuff into colours.py -- might be useful
to have this sort of thing available somewhere in matplotlib.
Re: the numbers in the table not matching up in the demo. The numbers I
put in the table are the total height of the columns, not just the
incremental heights (the place where I use these things are to show loss
statistics at different return periods + the users want to see the full
numbers not the incremental stuff). I've just re-read this para and it
is about as clear as mud, so yell if it isn't making sense alongside the
picture.
John
On Wed, 2004年02月11日 at 19:07, John Hunter wrote:
> >>>>> "John" == John Gill <jn...@eu...> writes:
> 
> >> If I could impose on you one more time. I would like to add a
> >> table screenshot to the web page. Something along the lines of
> >> the first table example you sent (with the stacked bar chart)
> >> but using data_table to build the table. The code should be as
> >> simple as possible since we want to emphasize the ease of use.
> >> Do you have some data you can use to make a table that can be
> >> displayed on the web? I have a data dir in the examples dir
> >> that I use to distribute data.
> 
> In anticipation of the 0.50 release, I did some reorganization of the
> table code to make it more consistent with other matplotlib commands.
> Eg,, data_table is now an axes function axes.table and at
> matplotlib.matlab command "table".
> 
> 
> 
> ______________________________________________________________________
> 
> I tried to adapt your various examples into a single demo using the
> new table command. It works ok, but the numbers in the table don't
> seem to always correspond to the respective sizes of the table. I
> don't fully have my head around the example - perhaps you can advise?
> 
> 
> 
> ______________________________________________________________________
> 
> Thanks!
> 
> JDH
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 によって変換されたページ (->オリジナル) /