E场景
我想用1秒的时间延迟更新热图的值。目的是描述一个强化学习问题中Q表的演化.
误差
问题是正在更新热图图,但值保持不变。

码
Q天生是一只全零熊猫DatraFrame。
函数创建海运热图:
# Helper functions to draw, update and get values of the table
def draw_Table(Q):
table = sns.heatmap(Q, cmap='Blues', annot=True, linewidths=.5, cbar=False,
linecolor='black', square=True).set_title('Q-Table')
return table 以下是主要功能:
plt.ion()
plt.figure(figsize = (10,10))
for i in range(EPISODES):
print('Episode [{}/{}]'.format(i,EPISODES))
print('Current Q-Table')
# Some code that updates the values of Q
# Update the new Q-Value
if 'previous' in globals(): del previous
previous = draw_Table(Q)
plt.pause(1)
plt.ioff()
plt.show()发布于 2018-09-07 20:44:17
(根据评论意见)找到了解决办法,用下列方法清除轴线:
# Update the new Q-Value
if 'previous' in globals():
previous.axes.clear()
previous = draw_Table(Q)这个问题被删掉,变成了一个答案。
https://stackoverflow.com/questions/52225856
复制相似问题