gca().xaxis.set_major_locator(NullLocator())
gca().yaxis.set_major_locator(NullLocator())
savefig('filename.pdf', bbox_inches='tight', pad_inches=0)
Removing white space around a saved image in matplotlib