Yingqiang Gao
Yingqiang Gao

Reputation: 999

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!

Upvotes: 2

Views: 9496

Answers (1)

mechanical_meat
mechanical_meat

Reputation: 169494

Use os.path.join:

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

Upvotes: 2

Related Questions