jupyter show gif

%matplotlib qt5

ps: remember Clear key ax.cla()and draw the same axon

import numpy as np
import matplotlib.pyplot as plt
# 分别画2010-2017的图
fig, ax = plt.subplots()
for year in range(2010, 2018):
    ax.cla() # 清除键(关键)
    cbar = (True if year==2010 else False) # 第一张图画色条,其余不画
    ax = sns.heatmap(globals()['c%s'%(year-2010)], cmap='Reds', vmax=1300, cbar_kws={
    
    'label': 'Number of DrugReports'},cbar=cbar) # cmap='jet'
    plt.xticks(list(range(0,26,5)),list(np.round(np.arange(x_min, x_max, (x_max-x_min)/10))))
    plt.yticks(list(range(0,16,5)),list(np.round(np.arange(y_min, y_max, (y_max-y_min)/3))))
    plt.title(f'The status of DrugReports in {year}')
#     plt.savefig(f'.\image\元胞自动机\The status of DrugReports in {year}.png', bbox_inches='tight', dpi=300, transparent=True)
    plt.xlabel('lng'); plt.ylabel('lat')
    plt.pause(1)  # 暂停1秒

Guess you like

Origin blog.csdn.net/Caiqiudan/article/details/112855861
gif