I have a python code to create a figure. After showing it with plt.show()
, I want to save the figure.
To avoid messing up the aspect ratio, resolution, etc, I do not want to use the savefig
-command in the code. Instead, I want to use the "save the figure" button from the figure window.
However, by default, it prompts my home folder as location for the save. I would like the save to automatically be in the directory where the code was executed.
How/where can I change this window default path for saving to the current folder (or somewhere else)?
I tried this command from Change directory to the directory of a Python script at the beginning but it did not help, even though gives the filename correctly:
os.chdir(os.path.dirname(__file__))