-
-
Notifications
You must be signed in to change notification settings - Fork 19
/
marimo_reactive_app.py
47 lines (35 loc) · 1016 Bytes
/
marimo_reactive_app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import marimo
__generated_with = "0.7.17"
app = marimo.App(width="medium")
@app.cell
def __():
import matplotlib.pyplot as plt
import numpy as np
plt.style.use('_mpl-gallery')
# make the data
np.random.seed(3)
x = 4 + np.random.normal(0, 2, 24)
y = 4 + np.random.normal(0, 2, len(x))
# size and color:
sizes = np.random.uniform(15, 80, len(x))
opacity = np.random.uniform(0, 1, len(x))
return np, opacity, plt, sizes, x, y
@app.cell
def __():
from tldraw import ReactiveColorPicker
import marimo as mo
widget = mo.ui.anywidget(ReactiveColorPicker())
widget
return ReactiveColorPicker, mo, widget
@app.cell
def __(np, opacity, plt, sizes, widget, x, y):
fig, ax = plt.subplots()
ax.set(xlim=(0, 8), xticks=np.arange(1, 8), ylim=(0, 8), yticks=np.arange(1, 8))
ax.scatter(x, y, s=sizes*5, color=widget.color, alpha=opacity)
plt.show()
return ax, fig
@app.cell
def __():
return
if __name__ == "__main__":
app.run()