bbox_extra_artists doesn't work for a table #1419

Closed
dmcdougall opened this Issue Oct 21, 2012 · 1 comment

Comments

Projects
None yet
2 participants
Member

dmcdougall commented Oct 21, 2012

After applying the changes in #1418.

Consider the following example:

import matplotlib
matplotlib.use('agg')
import matplotlib.pyplot as plt
import numpy as np

a = np.array([[ 100.        ,  152.84493519,  233.63122532,  263.7018431 ,
                259.22927686,  243.56305545],
              [ 100.        ,  147.64885749,  194.26319507,  156.2985505 ,
                169.1050851 ,  124.84312468],
              [ 100.        ,  195.46940792,  273.37157492,  296.54100691,
                271.93708044,  358.30174259],
              [ 100.        ,  216.44727433,  308.30389994,  243.70797244,
                335.3325307 ,  396.22671612]])
fig = plt.figure()
ax = fig.add_subplot(1,1,1)

y = np.mean(a, axis=0)
ind = range(len(y))
ax.bar(ind, y, facecolor='#777777',
       align='center', ecolor='black',
       bottom=4)

labels = ['a', 'b', 'c', 'd', 'e', 'f']
rowlab = ['row1', 'row2', 'row3', 'row4']
ax.set_xticklabels(labels)
ax.xaxis.set_visible(False)
the_table = ax.table(cellText=a, colLabels=labels, rowLabels=rowlab)

fig.savefig('table1.png', bbox_inches='tight')
fig.savefig('table2.png', bbox_inches='tight', bbox_extra_artsits=[the_table])

I get the following output for table1.png

table1

And for table2.png

table2

For some reason, it appears as though the bbox_extra_artists isn't taking the union of the bounding boxes properly.

Member

pelson commented Nov 9, 2012

This has been merged.

@pelson pelson closed this Nov 9, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment