import matplotlib.pyplot as plt
from random_walk import RandomWalk
# 创建一个RandomWalk实例,并将其包含的点都绘制出来
rw = RandomWalk()
rw.fill_walk()
plt.scatter(rw.x_values, rw.y_values, s = 15)
plt.show()
运行rw_visual.py的运行结果为:
C:\Users\qlh\AppData\Local\Programs\Python\Python35\python.exe E:/MATPLOTLIB/rw_visual.py
Traceback (most recent call last):
File "E:/MATPLOTLIB/rw_visual.py", line 7, in <module>
rw.fill_walk()
File "E:\MATPLOTLIB\random_walk.py", line 18, in fill_walk
while len(self.x_values) < self.num_points:
AttributeError: 'RandomWalk' object has no attribute 'x_values'
进程已结束,退出代码1