packages = ["numpy", "matplotlib",]
REPL
Hit play button or shift-enter to run code.
pyscript.write('output0', '', append=True)
pyscript.write('output1', '', append=False)
output0 ... output5 import numpy as np import matplotlib.pyplot as plt import matplotlib as mpl mpl.rcParams['axes.spines.top'] = False mpl.rcParams['axes.spines.right'] = False np.random.seed(19680801) data = {'a': np.arange(5), 'c': np.random.randint(0, 5, 5), 'd': np.random.randn(5)} data['b'] = data['a'] + 10 * np.random.randn(5) data['d'] = np.abs(data['d']) * 100 fig, ax = plt.subplots(figsize=(2, 2)) ax.scatter('a', 'b', c='c', s='d', data=data) ax.set(xlabel='entry a', ylabel='entry b') plt.show() pyscript.write('output1', fig) import numpy as np import matplotlib.pyplot as plt mpl.rcParams['axes.spines.top'] = False mpl.rcParams['axes.spines.right'] = False np.random.seed(19680801) data = {'a': np.arange(5), 'c': np.random.randint(0, 5, 5), 'd': np.random.randn(5)} data['b'] = data['a'] + 10 * np.random.randn(5) data['d'] = np.abs(data['d']) * 100 fig, ax = plt.subplots(figsize=(2, 2)) ax.scatter('a', 'b', c='c', s='d', data=data) ax.set(xlabel='entry a', ylabel='entry b') plt.show() pyscript.write('output1', fig)