So right now – my Python program (in a UNIX environment) can save files.
fig.savefig('forcing' + str(forcing) + 'damping' + str(damping) + 'omega' + str(omega) + 'set2.png')
How could I save it in a new directory without switching directories? I would want to save the files in a directory like Pics2/forcing3damping3omega3set2.png.
By using a full or relative path. You are specifying just a filename, with no path, and that means that it’ll be saved in the current directory.
To save the file in the
Pics2directory, relative from the current directory, use:or better still, construct the path with
os.path.join()and string formatting:Best is to use an absolute path: