I'm learning basics of matplotlib library with "Python Crash Course" by Eric Matthew. However, I've bogged on p. 337. When I was trying to hide axes as shown in the book, my visualization literally went crazy. The random walk disappeared and axes remained visible. What's going on here? And how can I fix it?
A code:
import matplotlib.pyplot as plt
from random_walk import RandomWalk
while True:
rw = RandomWalk(5000)
rw.fill_walk()
points_number = rw.x_points[:]
plt.scatter(rw.x_points, rw.y_points, s=15, c=points_number,
cmap = plt.cm.Greens, edgecolor='none')
plt.scatter(rw.x_points[0], rw.y_points[0], s=45, c='Red')
plt.scatter(rw.x_points[-1], rw.y_points[-1], s=45, c='Red')
plt.axes().get_yaxis().set_visible(False)
plt.axes().get_xaxis().set_visible(False)
plt.show()
answer = input('An another random walk? (Y/N) ')
if answer.upper().strip() == 'N':
break
An exemplary visualization:
https://i.stack.imgur.com/pb0Iq.jpg
I think something must be wrong with 12th and 13th lines. When I comment them out, the random walk appear again.