我正在尝试使用赛璐珞构建动画热图。x & y 轴和色标是相同的,但我的代码返回下面的奇怪输出。
我的代码使用 seaborn、numpy、pandas 和赛璐珞,并简化如下:
from celluloid import Camera
## Set up celluloid
fig = plt.figure(figsize=(12, 9))
camera = Camera(fig)
## Loop to create figures
for item in range(len(df)):
row = df.iloc[item]
row = np.array(list(row))
## Create df from row
shape = (8,12)
df_row = pd.DataFrame(row.reshape(shape))
## Build seaborn heatmap
ax = sns.heatmap(df_row, cmap="Greys", annot=False, vmin=0, vmax=1)
ax.set_title(item)
ax.xaxis.tick_top()
for tick in ax.get_yticklabels():
tick.set_rotation(0)
## Snap Celluloid
camera.snap()
anim = camera.animate(interval=500)
anim.save("animation.mp4")