Home > Enterprise >  Recieving an error when plotting and saving a graph with %matploblib.pyplot notebook
Recieving an error when plotting and saving a graph with %matploblib.pyplot notebook

Time:02-22

I am trying to save an interactive plot using %matplotlib.pyplot notebook, but I am recieving an error message that says 'list' object has not attribute 'png'.

Here is my code:

import matplotlib.pyplot as plt
plt.plot([1,2,3], [4,5,6])
plt.xlabel("x")
plt.ylabel("y")
plt.savefig(plot.png)

CodePudding user response:

The plt.savefig() method takes in a string representing the filname of the iage that will be saved to your computer; simply wrap the plot.png in quotes:

plt.savefig("plot.png")
  • Related