Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The matplotlib documentation says </p> <blockquote> <p>Add a table to the current axes. Returns a matplotlib.table.Table instance. For finer grained control over tables, use the Table class and add it to the axes with add_table().</p> </blockquote> <p>You could do is the following, look at the properties of your table (it's and object belonging to that class Table):</p> <pre><code>print the_table.properties() # hint it's a dictionary do: type(the_table.properties() &lt;type 'dict'&gt; </code></pre> <p>edit that dictionary the way you see right, and the update your table, with:</p> <pre><code>the_table.update(giveHereYourDictionary) </code></pre> <p>Hint: if you work with IPython or interactive shell it's enough to do help(objectName), e.g. help(the_table) to see all the object's methods. This should, hopefully, work.</p> <p>OK, I'm adding here a walk through of how to to that kind of stuff. I admit, it's not trivial, but I am using matplotlib for 3.5 years now, so ...</p> <p>Do your code in IPython (I said it before, but I must emphasize again), it really helps to examine all the properties that objects have (type object name and then the key):</p> <pre><code>In [95]: prop=the_table.properties() In [96]: prop #This is a dictionary, it's not so trivial, but never the less one can understand how dictionaries work... Out[96]: {'agg_filter': None, 'alpha': None, 'animated': False, 'axes': &lt;matplotlib.axes.AxesSubplot at 0x9eba34c&gt;, 'celld': {(0, -1): &lt;matplotlib.table.Cell at 0xa0cf5ec&gt;, (0, 0): &lt;matplotlib.table.Cell at 0xa0c2d0c&gt;, (0, 1): &lt;matplotlib.table.Cell at 0xa0c2dec&gt;, (0, 2): &lt;matplotlib.table.Cell at 0xa0c2ecc&gt;, (1, -1): &lt;matplotlib.table.Cell at 0xa0cf72c&gt;, (1, 0): &lt;matplotlib.table.Cell at 0xa0c2fac&gt;, (1, 1): &lt;matplotlib.table.Cell at 0xa0cf08c&gt;, (1, 2): &lt;matplotlib.table.Cell at 0xa0cf18c&gt;, (2, -1): &lt;matplotlib.table.Cell at 0xa0cf84c&gt;, (2, 0): &lt;matplotlib.table.Cell at 0xa0cf28c&gt;, (2, 1): &lt;matplotlib.table.Cell at 0xa0cf3ac&gt;, (2, 2): &lt;matplotlib.table.Cell at 0xa0cf4cc&gt;}, 'child_artists': [&lt;matplotlib.table.Cell at 0xa0c2dec&gt;, &lt;matplotlib.table.Cell at 0xa0cf18c&gt;, &lt;matplotlib.table.Cell at 0xa0c2d0c&gt;, &lt;matplotlib.table.Cell at 0xa0cf84c&gt;, &lt;matplotlib.table.Cell at 0xa0cf3ac&gt;, &lt;matplotlib.table.Cell at 0xa0cf08c&gt;, &lt;matplotlib.table.Cell at 0xa0cf28c&gt;, &lt;matplotlib.table.Cell at 0xa0cf4cc&gt;, &lt;matplotlib.table.Cell at 0xa0cf5ec&gt;, &lt;matplotlib.table.Cell at 0xa0c2fac&gt;, &lt;matplotlib.table.Cell at 0xa0cf72c&gt;, &lt;matplotlib.table.Cell at 0xa0c2ecc&gt;], 'children': [&lt;matplotlib.table.Cell at 0xa0c2dec&gt;, &lt;matplotlib.table.Cell at 0xa0cf18c&gt;, ...snip snap ... &lt;matplotlib.table.Cell at 0xa0cf72c&gt;, &lt;matplotlib.table.Cell at 0xa0c2ecc&gt;], 'clip_box': TransformedBbox(Bbox(array([[ 0., 0.], [ 1., 1.]])), CompositeAffine2D(BboxTransformTo(Bbox(array([[ 0., 0.], [ 1., 1.]]))), BboxTransformTo(TransformedBbox(Bbox(array([[ 0.25, 0.3 ], [ 0.95, 0.8 ]])), BboxTransformTo(TransformedBbox(Bbox(array([[ 0., 0.], [ 8., 6.]])), Affine2D(array([[ 80., 0., 0.], [ 0., 80., 0.], [ 0., 0., 1.]])))))))), 'clip_on': True, 'clip_path': None, 'contains': None, 'figure': &lt;matplotlib.figure.Figure at 0x9eaf56c&gt;, 'gid': None, 'label': '', 'picker': None, 'rasterized': None, 'snap': None, 'transform': BboxTransformTo(TransformedBbox(Bbox(array([[ 0.25, 0.3 ], [ 0.95, 0.8 ]])), BboxTransformTo(TransformedBbox(Bbox(array([[ 0., 0.], [ 8., 6.]])), Affine2D(array([[ 80., 0., 0.], [ 0., 80., 0.], [ 0., 0., 1.]])))))), 'transformed_clip_path_and_affine': (None, None), 'url': None, 'visible': True, 'zorder': 0} # we now get all the cells ... [97]: cells = prop['child_artists'] In [98]: cells Out[98]: [&lt;matplotlib.table.Cell at 0xa0c2dec&gt;, &lt;matplotlib.table.Cell at 0xa0cf18c&gt;, ... snip snap... &lt;matplotlib.table.Cell at 0xa0cf72c&gt;, &lt;matplotlib.table.Cell at 0xa0c2ecc&gt;] In [99]:cell=cells[0] In [100]: cell # press tab here to see cell's attributes Display all 122 possibilities? (y or n) cell.PAD cell.add_callback ...snip snap ... cell.draw cell.eventson cell.figure ...snip snap ... In [100]: cell.set_h cell.set_hatch cell.set_height # this looks promising no? Hell, I love python ;-) wait, let's examine something first ... In [100]: cell.get_height() Out[100]: 0.055555555555555552 In [101]: cell.set_height(0.1) # we just 'doubled' the height... In [103]: pyplot.show() </code></pre> <p>and TA DA:</p> <p><img src="https://i.stack.imgur.com/W2xaG.png" alt="Table with modified height for one cell"></p> <p>Now, I challege you to change the height of all the cells, using a for loop. Should not be so hard. Would be nice to win that bounty ;-)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload