I am struggling on how to find the correct way to specify the save path (or repository) when calling the function savefig in matplotlib or pylab.
I tried several syntaxes, but everytime python console returns :
FileNotFoundError: [Errno 2] No such file or directory: '../MyDocs/resource/frames/MyImage.png'
Currently, I have written the following :
pylab.savefig('../MyDocs/resource/frames/MyImage.png')
Does someone know how to do it?
For matplotlib.pyplot, the error FileNotFoundError: [Errno 2] No such file or directory
can occur due to nonexistence of the containing folder ../MyDocs/resource/frames/
.
So maybe first create the folder
import os
os.makedirs('../MyDocs/resource/frames/')
then rerun the savefig function.
The tilde operator and the variable $HOME
are entered as strings and therefore do not function while saving. You have to provide either relative path (as you did) or provide the full path. Eg. pylab.savefig("/home/username/Desktop/myfig.png")
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With