小编r s*_*zle的帖子

seaborn动画热图/相关矩阵

我是python的新手(来自matlab).作为一个项目,我试图创建一个随时间变化的相关矩阵的动画图.为了让情节变得美好,我正在尝试海盗.我很难完成动画制作(在mac上遇到matplotlib后端问题),但现在使用来自网络的代码可以使用一个非常基本的动画:

import numpy as np
from matplotlib import pyplot as plt
from matplotlib import animation

nx = 50
ny = 50

fig = plt.figure()
data = np.random.rand(nx, ny)
im = plt.imshow(data)

def init():
    im.set_data(np.zeros((nx, ny)))

def animate(i):
    #xi = i // ny
    #yi = i % ny
    data = np.random.rand(nx, ny)
    im.set_data(data)
    return im

anim = animation.FuncAnimation(fig, animate, init_func=init, frames=50, repeat = False)
Run Code Online (Sandbox Code Playgroud)

现在我试图将其改编为seaborn,但没有成功.似乎seaborn在次要情节上工作并且使这些动画变得更加困难.我得到的最好的东西是一种递归情节,其中seaborn.heatmaps被绘制在彼此之上.此外,im.set_data方法不可用.任何建议都非常感谢.非常感谢你.

最好的,拉尔夫.

python animation matplotlib heatmap seaborn

9
推荐指数
1
解决办法
5364
查看次数

标签 统计

animation ×1

heatmap ×1

matplotlib ×1

python ×1

seaborn ×1