Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import matplotlib.pyplot as plt
- from matplotlib import animation, rc
- from IPython.display import HTML
- from random import randint
- last_number = 1
- range_low = 1
- range_high = 100
- dim = range_high - range_low + 1
- numbers = np.arange(range_low, range_high + 1, dtype=int)
- numbers_map = np.zeros((dim, dim), dtype=int)
- fig = plt.figure()
- im = plt.imshow(numbers_map)
- def init():
- im.set_data(np.zeros((dim, dim)))
- return im
- def number_generator():
- while True:
- yield randint(range_low, range_high)
- def animate(number):
- numbers_map[last_number - range_low, number - range_low] += 1
- im.set_data(numbers_map)
- return im
- anim = animation.FuncAnimation(fig, animate, init_func=init, frames=number_generator, interval=100,
- blit=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement