From 070604bbe54d2bf66e3089c2f0e849c5199aad8b Mon Sep 17 00:00:00 2001 From: kushalkolar Date: Wed, 1 May 2024 03:09:25 -0400 Subject: [PATCH] simple scatter animation example in quickstart --- examples/notebooks/quickstart.ipynb | 47 ++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/examples/notebooks/quickstart.ipynb b/examples/notebooks/quickstart.ipynb index c40e5c9ff..84886ecae 100644 --- a/examples/notebooks/quickstart.ipynb +++ b/examples/notebooks/quickstart.ipynb @@ -1361,6 +1361,16 @@ "fig_em[0, 0].add_animations(tick)" ] }, + { + "cell_type": "code", + "execution_count": null, + "id": "774dba2e-f4c1-4c97-a427-c6f447139342", + "metadata": {}, + "outputs": [], + "source": [ + "fig_em.close()" + ] + }, { "cell_type": "markdown", "id": "a202b3d0-2a0b-450a-93d4-76d0a1129d1d", @@ -1410,7 +1420,7 @@ "fig_scatter = fpl.Figure()\n", "subplot_scatter = fig_scatter[0, 0]\n", "# use an alpha value since this will be a lot of points\n", - "scatter_graphic = subplot_scatter.add_scatter(data=cloud, sizes=3, colors=colors, alpha=0.7)\n", + "scatter_graphic = subplot_scatter.add_scatter(data=cloud, sizes=3, colors=colors, alpha=0.6)\n", "\n", "fig_scatter.show()" ] @@ -1434,6 +1444,17 @@ "scatter_graphic.colors[:n_points:2] = \"r\"" ] }, + { + "cell_type": "code", + "execution_count": null, + "id": "a5962263-8032-40ad-9981-fa0a649e2643", + "metadata": {}, + "outputs": [], + "source": [ + "# other half of the first cloud's points to purple\n", + "scatter_graphic.colors[1:n_points:2] = \"purple\"" + ] + }, { "cell_type": "code", "execution_count": null, @@ -1497,6 +1518,30 @@ "subplot_scatter.controller = \"fly\"" ] }, + { + "cell_type": "markdown", + "id": "43ae13f1-d59b-4673-b0b3-669542b4c127", + "metadata": {}, + "source": [ + "## Animation\n", + "\n", + "Move the cloud by a small delta on every render cycle" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "50d2e96f-718c-4925-9e81-a92e81134741", + "metadata": {}, + "outputs": [], + "source": [ + "def update_points(subplot):\n", + " deltas = np.random.normal(size=scatter_graphic.data().shape, loc=0, scale=0.15)\n", + " scatter_graphic.data = scatter_graphic.data() + deltas\n", + "\n", + "subplot_scatter.add_animations(update_points)" + ] + }, { "cell_type": "code", "execution_count": null,