python - How to change the path of matplotlib.pyplot.save
为情所困
为情所困 2017-05-18 10:45:14
0
1
1489

By default, it is always saved in the same folder as the py file. How can I change the path and save the generated image on the path I want?

为情所困
为情所困

reply all(1)
PHPzhong

In matplotlib, pyplot does not have a save function. If you want to save a picture, you can refer to the following simple example:

>>> from matplotlib import pyplot as plt
>>> x=[2,5]
>>> y=[4,9]
>>> plt.plot(x,y)
>>> plt.savefig('D:\img.jpg')

Of course you can also save it in PDF format:

>>> plt.savefig('D:\img.pdf')

matplotlib will handle this part of the work automatically.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template