#!/usr/bin/env python # coding: utf-8 # In[ ]: import micropip await micropip.install("matplotlib") await micropip.install("ipympl") # In[ ]: import numpy as np import matplotlib.pyplot as plt import time # In[ ]: get_ipython().run_line_magic('matplotlib', 'widget') def pltsin(ax, colors=['b']): x = np.linspace(0,1,100) if ax.lines: for line in ax.lines: line.set_xdata(x) y = np.random.random(size=(100,1)) line.set_ydata(y) else: for color in colors: y = np.random.random(size=(100,1)) ax.plot(x, y, color) fig.canvas.draw() # In[ ]: fig,ax = plt.subplots(1,1) ax.set_xlabel('X') ax.set_ylabel('Y') ax.set_xlim(0,1) ax.set_ylim(0,1) plt.show() # In[ ]: for f in range(5): pltsin(ax, ['b', 'r']) time.sleep(1) # In[ ]: