Python Forum
mathplotlib savefig FileNotFoundError
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
mathplotlib savefig FileNotFoundError
#1
Hi!

I've made a figure using matplotlib and now I'm trying to save it to file using matplotlib.pyplot.savefig
import matplotlib.pyplot as plt

# . . .

plt.savefig("result.png")
Unfortunately it occurs FileNotFoundError at plt.savefig call.

Does anybody know, how can this problem be solved?
Reply
#2
(May-07-2019, 09:54 AM)drinkOut Wrote: Unfortunately it occurs FileNotFoundError at plt.savefig call.


Please post full traceback you get in error tags. Also it would be nice to post full code (minimal verifiable example that reproduce the problem).
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
Jupyter Notebook cell:
import matplotlib
import matplotlib.pyplot as plt
import numpy as np

y = [2,4,6,8,10,12,14,16,18,20]
x = np.arange(10)
fig = plt.figure()
ax = plt.subplot(111)
ax.plot(x, y, label='$y = numbers')
plt.title('Legend inside')
ax.legend()
#plt.show()

fig.savefig('plot.png')
Error trace:
Reply
#4
The code work when i test in Jupyter Notebook.
Try this,so for me plot.png get save in C:\\1_notebook.
A folder i have made to keep all notebooks.
import os

os.getcwd()
Output:
'C:\\1_notebook'
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Error : (FileNotFoundError(2, 'The system cannot find the file specified', None, 2, Shipika 3 3,533 Nov-25-2019, 02:39 PM
Last Post: buran
  mathplotlib Romanefr 1 2,965 May-21-2018, 10:19 AM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020