gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-04 05:11:00 25 4
gpt4 key购买 nike

我想将图形保存在给定的路径下,编写如下代码:

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

但实际上python只是将数字命名为“1-153Umlauf1.png”,它们都保存在桌面上。如何将图形保存在文件夹 1-153Umlauf 中?

谢谢大家!

最佳答案

使用os.path.join :

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

关于Python 保存图 : how to save the figure in a given path using savefig from matplotlib,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42986694/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com