John,
Thanks very much for the reply and sample code - my request was
actually a little different.
What I really want is a table with no axes/plot at all - just the table.
I had tried what your example suggested but could not get around
drawing axes.
I usually use Tex to build my tables but I saw the table demo in the
examples and thought that this might be a more automated method.
--Jim
On Dec 31, 2005, at 6:24 AM, John Hunter wrote:
>>>>>> "James" == James Boyle <boyle5@...> writes:
>
> James> Say I wanted to construct a table, just a table,
> James> independent of any graph etc. Just like the example
> James> table_demo.py but without the bar chart.
>
> The bar chart is incidental to this example. You can plot whatever
> you want in an axes and then issue the table command to generate the
> table below (or in some other place) around the axes.
>
> Eg, in the example below, I issue a plot command and remove the bar
> command from the table_demo in the examples dir (the "colours" module
> is also in the examples directory).
>
> JDH
>
> #!/usr/bin/env python
> import matplotlib
>
> from pylab import *
> from colours import get_colours
>
> axes([0.2, 0.2, 0.7, 0.6]) # leave room below the axes for the table
> plot([1,2,3])
>
>
> data = [[ 66386, 174296, 75131, 577908, 32015],
> [ 58230, 381139, 78045, 99308, 160454],
> [ 89135, 80552, 152558, 497981, 603535],
> [ 78415, 81858, 150656, 193263, 69638],
> [ 139361, 331509, 343164, 781380, 52269]]
>
> colLabels = ('Freeze', 'Wind', 'Flood', 'Quake', 'Hail')
> rowLabels = ['%d year' % x for x in (100, 50, 20, 10, 5)]
>
> # Get some pastel shades for the colours
> colours = get_colours(len(colLabels))
> colours.reverse()
> rows = len(data)
>
> ind = arange(len(colLabels)) + 0.3 # the x locations for the groups
> cellText = []
> width = 0.4 # the width of the bars
> yoff = array([0.0] * len(colLabels)) # the bottom values for stacked
> bar chart
> for row in xrange(rows):
> yoff = yoff + data[row]
> cellText.append(['%1.1f' % (x/1000.0) for x in yoff])
>
> # Add a table at the bottom of the axes
> colours.reverse()
> cellText.reverse()
> the_table = table(cellText=cellText,
> rowLabels=rowLabels, rowColours=colours,
> colLabels=colLabels,
> loc='bottom')
> ylabel("Loss $1000's")
>
> xticks([])
> title('Loss by Disaster')
>
> show()
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep through log
> files
> for problems? Stop! Download the new AJAX search engine that makes
> searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
> http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
|