For some of my script to work, a LaTeX installation is required. Additionally, ghostscript is required to save the figures as .eps plots which is normally what I save them as.
Ghostscript is not normally found on a windows system. Luckily, there is a compiled binary.
C:\Program Files\gs\gs9.27\bin
or something similar.There are plenty of tutorials on the internet. But here are some tips, that I have found useful and have been hard to find
matplotlib creates a lot of white space around figures. I got this recipe online, and I've edited it and it seems to work.
import matplotlib.pyplot as plt
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())
fig.tight_layout()
plt.show()