This code.:
import matplotlib.pyplot as plt
fig = plt.get_figure()
fig.savefig("myplot1.pdf")
Gives the following error:
AttributeError: 'module' object has no attribute 'get_figure'
How can I amend this?
This code.:
import matplotlib.pyplot as plt
fig = plt.get_figure()
fig.savefig("myplot1.pdf")
Gives the following error:
AttributeError: 'module' object has no attribute 'get_figure'
How can I amend this?
First of all check whether a function exists or not in a module or library then only proceed. Also please explain the question with relevant or example data.
You can save the figure in matplotlib.pyplot as shown.
import matplotlib.pyplot as plt
plt.scatter(x=[0,1,2,3,4,5],y=[0,1,2,3,4,5])
plt.savefig('saved_figure') #figure will be saved as saved_figure.png
plt.savefig('saved_figure.pdf') #figure will be saved as saved_figure.pdf
The Saved Figure will look like this and it will be saved in working directory.
The Saved Figure in pdf format.