简体   繁体   中英

Python savefig: how to save the figure in a given path using savefig from matplotlib

I want to save the figures in a given path, and write the following code:

savefig('/Users/gaoyingqiang/Desktop/1-153Umlauf'+str(p)+'.png')

But in fact python only names the figures "1-153Umlauf1.png", and they are all saved on the desktop. How can I save the figures in the folder 1-153Umlauf?

Thanks everyone!

使用os.path.join

output_path = os.path.join('/Users/gaoyingqiang/Desktop/1-153Umlauf',str(p)+'.png')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM