Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b79610c

Browse files
authored
simple scatter animation example in quickstart (#500)
1 parent b2cf625 commit b79610c

File tree

1 file changed

+46
-1
lines changed

1 file changed

+46
-1
lines changed

examples/notebooks/quickstart.ipynb

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1361,6 +1361,16 @@
13611361
"fig_em[0, 0].add_animations(tick)"
13621362
]
13631363
},
1364+
{
1365+
"cell_type": "code",
1366+
"execution_count": null,
1367+
"id": "774dba2e-f4c1-4c97-a427-c6f447139342",
1368+
"metadata": {},
1369+
"outputs": [],
1370+
"source": [
1371+
"fig_em.close()"
1372+
]
1373+
},
13641374
{
13651375
"cell_type": "markdown",
13661376
"id": "a202b3d0-2a0b-450a-93d4-76d0a1129d1d",
@@ -1410,7 +1420,7 @@
14101420
"fig_scatter = fpl.Figure()\n",
14111421
"subplot_scatter = fig_scatter[0, 0]\n",
14121422
"# use an alpha value since this will be a lot of points\n",
1413-
"scatter_graphic = subplot_scatter.add_scatter(data=cloud, sizes=3, colors=colors, alpha=0.7)\n",
1423+
"scatter_graphic = subplot_scatter.add_scatter(data=cloud, sizes=3, colors=colors, alpha=0.6)\n",
14141424
"\n",
14151425
"fig_scatter.show()"
14161426
]
@@ -1434,6 +1444,17 @@
14341444
"scatter_graphic.colors[:n_points:2] = \"r\""
14351445
]
14361446
},
1447+
{
1448+
"cell_type": "code",
1449+
"execution_count": null,
1450+
"id": "a5962263-8032-40ad-9981-fa0a649e2643",
1451+
"metadata": {},
1452+
"outputs": [],
1453+
"source": [
1454+
"# other half of the first cloud's points to purple\n",
1455+
"scatter_graphic.colors[1:n_points:2] = \"purple\""
1456+
]
1457+
},
14371458
{
14381459
"cell_type": "code",
14391460
"execution_count": null,
@@ -1497,6 +1518,30 @@
14971518
"subplot_scatter.controller = \"fly\""
14981519
]
14991520
},
1521+
{
1522+
"cell_type": "markdown",
1523+
"id": "43ae13f1-d59b-4673-b0b3-669542b4c127",
1524+
"metadata": {},
1525+
"source": [
1526+
"## Animation\n",
1527+
"\n",
1528+
"Move the cloud by a small delta on every render cycle"
1529+
]
1530+
},
1531+
{
1532+
"cell_type": "code",
1533+
"execution_count": null,
1534+
"id": "50d2e96f-718c-4925-9e81-a92e81134741",
1535+
"metadata": {},
1536+
"outputs": [],
1537+
"source": [
1538+
"def update_points(subplot):\n",
1539+
" deltas = np.random.normal(size=scatter_graphic.data().shape, loc=0, scale=0.15)\n",
1540+
" scatter_graphic.data = scatter_graphic.data() + deltas\n",
1541+
"\n",
1542+
"subplot_scatter.add_animations(update_points)"
1543+
]
1544+
},
15001545
{
15011546
"cell_type": "code",
15021547
"execution_count": null,

0 commit comments

Comments
 (0)