Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

remove whitespace around figure matplotlib

plt.gca().set_axis_off()
plt.subplots_adjust(top = 1, bottom = 0, right = 1, left = 0, 
            hspace = 0, wspace = 0)
plt.margins(0,0)
plt.gca().xaxis.set_major_locator(plt.NullLocator())
plt.gca().yaxis.set_major_locator(plt.NullLocator())
plt.savefig("filename.pdf", bbox_inches = 'tight',
    pad_inches = 0)

# contributor was unsure about how it works, but nonetheless, it works!
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #remove #whitespace #figure #matplotlib
ADD COMMENT
Topic
Name
1+4 =