为什么代码运行后图片无法显示啊,代码如下
import matplotlib.pyplot as pt
from random import choice
class RandomWalk:
def __init__(self,point=5000):
self.point=point
self.x=[0]
self.y=[0]
def walktrace(self):
while len(self.x)<self.point:
self.xdirection=choice([-1,0,1])
self.xstep=choice([1,2,3,4,5])
self.xtrace=self.xdirection*self.xstep
x=self.x[-1]+self.xtrace
self.ydirection=choice([-1,0,1])
self.ystep=choice([1,2,3,4,5])
self.ytrace=self.ydirection*self.ystep
y=self.y[-1]+self.ytrace
self.x.append(x)
self.y.append(y)
def draw(self):
fig,ax=pt.subplots()
ax.scatter(self.x,self.y,c='red',s=10)
pt.show()