I am trying to learn Python. I am using the following program, which creates the image OK, but I want to save it. I tried some instructions I found on this site, but am getting the error message at the bottom. Any help would be appreciated.
Program:
import sys
import random
import matplotlib as plt
from graphics import *
def main():
m=1
n=2
offset=50
win = GraphWin("MyWin",500, 500)
win.setBackground(color_rgb(0,0,0))
for i in range(1,1000,1):
r= random.uniform(0,1)
q= int(3*r)
m = (m/2) + q*(q-1)*75
n = (n/2) + q*(3-q)*75
pt = Point(m + offset,n + offset)
pt.setOutline(color_rgb(255,255,0))
pt.draw(win)
print("graphic done")
plt.savefig("figure.png")
win.getMouse()
win.close()
if __name__ == '__main__':
main()
Error Message:
graphic done
Traceback (most recent call last):
File "fractal_1.py", line 29, in <module> main()
File "fractal_1.py", line 24, in main
plt.savefig("figure.png")
AttributeError: module 'matplotlib' has no attribute 'savefig'