remove whitespace around figure matplotlib

Solutions on MaxInterview for remove whitespace around figure matplotlib by the best coders in the world

showing results for - "remove whitespace around figure matplotlib"
Prune
09 Feb 2017
1plt.gca().set_axis_off()
2plt.subplots_adjust(top = 1, bottom = 0, right = 1, left = 0, 
3            hspace = 0, wspace = 0)
4plt.margins(0,0)
5plt.gca().xaxis.set_major_locator(plt.NullLocator())
6plt.gca().yaxis.set_major_locator(plt.NullLocator())
7plt.savefig("filename.pdf", bbox_inches = 'tight',
8    pad_inches = 0)
9
10# contributor was unsure about how it works, but nonetheless, it works!
11