Where do images get saved in Matplotlib when using savefig?


#1

Question

Where do images get saved in Matplotlib when using savefig?

Answer

When running in the Codecademy interface, the savefig() function will not save the image files anywhere, due to the interface being completely online with no implementation to save on your computer.

However, if you run this outside of Codecademy, such as on Jupyter Notebook, it will save the image file to the current directory by default. If needed, you can also specify a file path instead of a file name to save the image in a specified directory. For example, if the directory is a path within your current directory, you can save it like so,

plt.savefig('subfolder/filename.png')