I'm using matplotlib and python 2.7 to create some tables. When I save the tables, the images come out square, even if the table is only 1 - 2 rows, creating a lot of empty space when I add them to an auto-generated PDF later. The an example of how I'm using the code is here...
import matplotlib.pyplot as plt
t_data = ((1,2), (3,4))
table = plt.table(cellText = t_data, colLabels = ('label 1', 'label 2'), loc='center')
plt.axis('off')
plt.grid('off')
plt.savefig('test.png')
This produces an image like this... You can see you can see the white space around it
Weirdly using plt.show()
produces the table in the GUI without white space.
I've tried using various forms of tight_layout=True
without luck, as well as making the background transparent (it becomes transparent, but is still there).
Any help would be greatly appreciated.