import numpy as np from matplotlib import pyplot as plt import datetime figure = plt.figure() # ax = figure.add_subplot(1,1,1) # ax.spines['top'].set_visible(False) # ax.spines['right'].set_visible(False) while True: # x = np.random.randint(1,100) x = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') #只能使用全局变量才能更改对应的对象 plt.xticks([]) plt.yticks([]) plt.text(0.25,0.5,x,fontsize=20) print(i) plt.pause(1) # 清空前边成图的对象 plt.clf()
matplotlib是绘图的一个工具,所以对于每个可操作元素的控制,如果按照指定的想法去控制对应的元素,就会有许多更加合理的方式来表达数据中所包含的信息。数据在成图时,如果添加了时间维度,即数据的变化会动起来,这样数据的变化就会显得更加直观。也更符合人的感观。