0
我正在创建一个颜色网格,它需要一些原始用户输入,如:定义的脚本运行时间,随机信号数量,样本数量和归一化0或1。鼠标,其中一列或框应变为红色,表示“高”,而其他框/柱保持蓝色,黄色或绿色。基于鼠标点击事件的动画颜色网格
到目前为止,我有以下代码,但除了能够显示示例颜色网格之外,我没有取得任何进展。我可以采取哪些步骤来执行原始输入并生成随机信号?
from pylab import arange, cm, draw, rand
from matplotlib import pylab as plt
from time import sleep
import time
start_time = time.time()
plt.ion()
a = arange(25)
a = a.reshape(5,5)
fig = plt.figure(figsize = (5, 5))
for i in range(100):
ax = fig.add_subplot(111)
b = 5*rand(5,5)
cax = ax.matshow(a-b, cmap=cm.jet, vmin = -10, vmax = 25)
if i == 0:
fig.colorbar(cax)
draw()
sleep(0.01)
plt.show()
print("--- %s seconds ---" %(time.time() - start_time))